0% found this document useful (0 votes)
1 views4 pages

Learn JavaScript

JavaScript is a widely-used, easy-to-learn scripting language that powers web development and supports both client-side and server-side scripting. It is lightweight, platform-independent, and allows for event-based programming, with features such as input validation and function creation. The document also explains the switch statement in JavaScript, detailing its syntax and functionality for executing code based on different conditions.

Uploaded by

Lakhan Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

Learn JavaScript

JavaScript is a widely-used, easy-to-learn scripting language that powers web development and supports both client-side and server-side scripting. It is lightweight, platform-independent, and allows for event-based programming, with features such as input validation and function creation. The document also explains the switch statement in JavaScript, detailing its syntax and functionality for executing code based on different conditions.

Uploaded by

Lakhan Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Learn JavaScript

 JavaScript is an interpreted an interpreted scripting language.


 JavaScript is the world's most popular programming language.
 JavaScript is the programming language of the Web.
 JavaScript is easy to learn.
 This tutorial will teach you JavaScript from basic to advanced.

Features of JavaScript :
1) JavaScript is light weight scripting language because it does not support all features
of object oriented programming languages.
2) No need of special software to run JavaScript programs
3) JavaScript is object oriented scripting language and it supports event based
programming facility. It is case sensitive language.
4) JavaScript helps the browser to perform input validation without wasting the user's
time by the Web server access.
5) It can handle date and time very effectively.
6) Most of the JavaScript control statements syntax is same as syntax of control
statements in other programming languages.
7) An important part of JavaScript is the ability to create new functions within scripts.
Declare a function in JavaScript using function keyword.
8) Software that can run on any hardware platform (PC, Mac, SunSparc etc.) or .
software platform (Windows, Linux, Mac OS etc.) is called as platform independent
software. JavaScript is platform independent scripting language. Any JavaScript-
enabled browser can understand and interpreted JavaScript code. Due to different
features, JavaScript is known as universal client side scripting language.

There are two types of scripting :


1) Server side scripting
2) Client side scripting.

Difference between Server side scripting and Client Side Scripting


Server side scripting Client Side Scripting
1.Defination: 1.Defination:
Server-side scripting is used at the client- side scripting is used at the frontend
backend, where the source code is not which users can see from the browser.
visible or hidden at the client side
(browser).
2. Security: 2. Security:
Server-side scripting is more secure. client- side scripting is not secure.

3. interaction: 3. interaction:
When a server-side script is processed client-side scripting does not
it communicates to the server need any server interaction.
4. language involves: 4. language involves:
The client-side scripting language programming languages such as PHP,
involves languages such as HTML5, ASP.net, Ruby, ColdFusion, Python,
JavaScript etc. C# etc. are server side scripting
languages.
5.Requirment: 5.Requirment:
Server-side scripting is useful in the client- side scripts are generally used for
customizing the web pages and validation purpose and effectively
implements the dynamic changes in minimize the load to the server.
the websites.
6.Execut: 6.Execut:
Special software (web server whereas client side
software) is required to execute scripts requires web browser as an
server-side script interface.

JavaScript Switch Statement


The switch statement is used to perform different actions based on different
conditions.
The JavaScript Switch Statement
Use the switch statement to select one of many code blocks to be executed.
Syntax
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
This is how it works:

 The switch expression is evaluated once.


 The value of the expression is compared with the values of each case.
 If there is a match, the associated block of code is executed.
 If there is no match, the default code block is executed.

Exampl:

<html>

<head>

<title>Switch Case

</title>

</head>

<body>

<h1>Example of Switch Case</h1>

<script type="text/javascript">

var day=8;

switch(day)

case 1:alert("Monday");break;

case 2:alert("Tuesday");break;

case 3:alert("wednesday");break;

case 4:alert("Thuesday");break;

case 5:alert("Saturdayday");break;

case 6:alert("Sunday");break;

default:alert("Invalid Day");

}
</script>

</body>

</html>

The break Keyword


When JavaScript reaches a break keyword, it breaks out of the switch block.

This will stop the execution inside the switch block.

It is not necessary to break the last case in a switch block. The block breaks (ends)
there anyway.

Note: If you omit the break statement, the next case will be executed even if the
evaluation does not match the case.

The default Keyword


The default keyword specifies the code to run if there is no case match:

You might also like