Page 188 - Web_Application_v2.0_C12_Fb
P. 188
name: "Rohan",
age: 30,
city: "Mumbai"
};
Array: A special type of object that represents an ordered list of values.
For example:
var colours = ["Red", "Green", "Blue"];
Function: Functions in JavaScript are also objects and can be assigned to variables, passed as arguments,
and returned from other functions.
For example:
function greetings() {
return "Hello, friend!";
}
Date: A date object represents a date and time.
For example:
var todayDate= new Date();
RegExp: A regular expression is a pattern for matching strings.
For example:
var pattern = /hello/i;
2.5 STATEMENTS IN JAVASCRIPT
In JavaScript, statements are commands or instructions given to the interpreter to perform specific actions. A
script or program is simply a collection of such statements. Most modern web browsers come with a built-in
JavaScript interpreter to execute these commands.
While semicolons (;) are typically used to end a statement, they can be omitted if each statement is written
on a separate line.
JavaScript statements are made up of variables, keywords, operators, expressions, and comments — let’s dive
into each of these components in detail.
Variables
A variable is a named storage location that holds a value, which can be updated later. JavaScript is a loosely
typed language, meaning you don’t need to specify a data type when declaring a variable. The identifier
refers to the variable's name.
The syntax for declaring a variable in JavaScript is:
var <variable name> = <value>;
where var is a keyword, <variable name> is a valid name for the variable and <value> is the value that you
want to assign the variable.
For example:
var myAge = 31;
var name = "Aarav";
186 Touchpad Web Applications (Ver. 2.0)-XII

