JavaScript was originally
developed by Brendan Eich at Netscape in 1995, back then the language was
called LiveScript. In 1997 JavaScript became an ECMA standard. ECMA-267 is the
official name of the standard; ECMAScript is the official name of the language.
In early December 1995, just prior to the formal release of the Netscape2,
Netscape and Sun jointly announced that the scripting language thereafter would
be known as JavaScript.
"Netscape2 was the first browser to run
javaScript in 1995."
·
JavaScript is a light weight,
interpreted programming language.
·
Designed for creating network centric
applications.
·
It is open and cross platform.
Client-side JavaScript is the most
common form of the language. The script should be included in or referenced by
an HTML document for the code to be interpreted by the browser. It means that a
web page need not be a static HTML, but can include programs that interact with
the user, control the browser, and dynamically create HTML content.
You can use JavaScript to check if
the user has entered a valid e-mail address in a form field. JavaScript can be
used to trap user-initiated events such as button clicks, link navigation, and
other actions that the user initiates explicitly or implicitly.
Advantages of
JavaScript
·
Less server interaction: You can validate user input
before sending the page off to the server. This saves server traffic, which
means less load on your server.
·
Increased interactivity: You can create interfaces that
react when the user hovers over them with a mouse or activates them via the
keyboard.
·
Immediate feedback to the visitors: visitors don't
have to wait for a page reload to see if they have forgotten to submit required
information.
·
Richer interfaces: You can use JavaScript to include such
items as drag-and-drop components and sliders to give a Rich Interface to your
site visitors.
Case
Sensitivity
JavaScript is a case-sensitive
language. This means that language keywords, variables, function names, and any
other identifiers must always be typed with a consistent capitalization of
letters. The while keyword, for example, must be typed “while”, not
“While” or “WHILE”.
Dynamically Typed Language
JavaScript is a dynamically typed language,
JavaScript data types are converted automatically as needed during execution. For
Example..
<script>
var
myVar=70; // as a string variable with
70 value
document.write(myVar);
//output 70
myVar=“YourName”;
document.write(myVar); //output YourName
</script>
Comments in JavaScript
In JavaScript single line
comment start with //
Example
<script>
//write sum of 5+6
document.write(5+6);
</script>
In JavaScript Multi Line Comments start with /* and
End with */
Example
<script>
/*write sum
of 5+6
Multiline
comment */
document.write(5+6);
</script>
Data types In JavaScript
We have three categories of data types in
JavaScript
·
Numbers – Like 12, 3.72
·
Boolean – true/false
·
String – “FirstName”, ‘FirstName’
Declaring JavaScript Variables
To create a JavaScript variable we use var keyword. All JavaScript variable
must be identified with unique names and these unique names are called
identifiers
Example
var firstName;
After
declaring a variable use =(equal sign) to assign value.
Example
firstName=“MyfirstName“;
Variable declaration with value
Example
var
LastName=“MyLastName”;
A variable declared without value will have the
value undefined.
0 Comments