Variables

Variables are containers, you can store data by defining a keyword called var.

var name;
name = 'shruthi';
This var keyword can contain a value of any datatype i.e
String:
var name = 'shruthi';

Number:
var count = 10;

Boolean:
var online = true;

Array:
var myArray = ["hello","hi"];
This can be retrieved as :

myArray[0] = 'hello';
myArray[1] = 'hi';

Object:
 Anything which can be stored in a variable can be defined as an object. The above mentioned examples too.
<div class='myClass'>hello</div>
<script>
var myObject = document.querySelector(".myClass").style.backgroundColor = "red";
</script>





No comments:

Post a Comment

Overview of AngularJS

AngularJS is an open source web application framework. It is now maintained by Google . The most of the code can be eliminated by using th...