Home > DeveloperSection > Blogs > JavaScript Introduction

JavaScript Introduction


JavaScript JavaScript  Java 
Ratings:
0 Comment(s)
 115  View(s)
Rate this:

JavaScript Introduction


JavaScript is an easy-to-use programming language of HTML and the web.  This language increases the dynamic and interactive features of web page by allowing you to check forms, perform calculation, add special effects, create security passwords, writes interactive games, customized graphics selection and many more.

JavaScript is an interpreted light weight programming language. This programming language is used to create network-centric application. Implementation of JavaScript is very easy as it is integrated with HTML. It is open source and cross platform.

Following is the syntax of JavaScript:

<html>

<body>

<p>Example of JavaScript.</p>

 

<p>The variables a,b , and c  are assigned the values 50, 60, and 110:</p>

 

<p id="example"></p>

 

<script>

var a = 50;   // var is a keyword which is used to define a variale

var b = 60;

var c = a+ b;

document.getElementById("example").innerHTML = c; // c is the result of a and b which gives 110.

</script>

 

</body>

</html>

 

Note: JavaScript statements are separated by semicolon. JavaScript statements are composed of operators, value, expression, comments and keywords.

JavaScript values

The javascript has two variables: Fixed value and variable values.

Fixed values are also known as literals.

JavaScript Literals

The necessary rules for writing fixed values are:

Numbers can be written with or without decimals.for example:

// literals can be with floating point or without.

12

12.32

Strings are text, written within single quotes or double quotes:

“Rachel”

 

‘Rachel’

 

JavaScript Variables

In any programming language, variables are used to store record.

JavaScript programming language uses the var keyword to declare variables.

An equal sign is used to assign data to variables.

In this below example, a is a variable. Then, a is assigned the value 6:

var a ;

a=6;

JavaScript Operators

JavaScript programming language uses an assignment operator ( = ) to assign record to variables:

<p id="example"></p>

<script>

var a = 5;

var b = 6;

document.getElementById("example ").innerHTML = a + b;

</script>

JavaScript programming language uses arithmetic operators ( + - *  / ) to calculate values:

<p id="example"></p>

<script>

document.getElementById("example").innerHTML = (5 + 6) * 10;

</script>

JavaScript Expressions

An expression is a combination of variables, values, and operators, which calculate the records.

The process called an evaluation. Following is an example:

<p id="demo"></p>

<script>

document.getElementById("demo").innerHTML = 50 * 110;

</script>

JavaScript Keywords

JavaScript keywords identify actions to be performed.

The var keyword is used to create a new variable:

<p id="example"></p>

<script>

var a = 50 + 60;

var b = a * 110;

document.getElementById("example").innerHTML = b;

</script>

JavaScript Comments

Code written after double slashes // or code between /* and */ is treated as a comment.

These comments are ignored, and will not be executed:

JavaScript is Case Sensitive

All JavaScript are case sensitive which means variables var Name and var name, are two different variables.

JavaScript DataTypes

Data types one of the most important characteristics of a programming language. These are the type of data which is used to represent and manipulate in a programming language.

There are three types of data types in JavaScrip −

·        Numbers, eg. 2123, 1220.250 etc.

·        Strings of text e.g. "This is my first JavaScript program" etc.

·        Boolean e.g. true or false.

Two trivial data types, null and undefined are also defined in JavaScript  which defines only single value. JavaScript also supports a composite data type known as object. We will discuss objects in detail in next article.


Don't want to miss updates? Please click the below button!

Follow MindStick