unit 4
unit 4
Used to concatenate
the words.
Alert function in JavaScript
JavaScript Variable
A JavaScript variable is simply a name of storage location. There are two types of variables in
JavaScript : local variable and global variable.
There are some rules while declaring a JavaScript variable (also known as identifiers).
JavaScript provides different data types to hold different types of values. There are two types of data
types in JavaScript.
1.Primitive data type
2.Non-primitive (reference) data type
JavaScript is a dynamic type language, means you don't need to specify type of the variable
because it is dynamically used by JavaScript engine. You need to use var here to specify the data
type. It can hold any type of values such as numbers, strings etc.
For example:
3.var a=40;//holding number
4.var b="Rahul";//holding string
JavaScript non-primitive data types
Here, you need to create instance of array by passing arguments in constructor so that we don't
have to provide value explicitly.
The example of creating object by array constructor is given below.