Some of the most common terms are:
Variable: A named location for storing values that can be changed during program execution.
Constant: A named location for storing values that cannot be changed during program execution.
Function: A named set of statements that perform some operation and can optionally return a single value.
Operator: Typically a symbol (such as +, -, *, or / ) that takes one or more values (called operands) and returns a result.
Expression: A combination of keywords, operators, variables, and/or functions from which a result can be calculated.
String: A sequence of 0 or more letters, numbers, or other text characters; strings are typically enclosed in quotation marks, as in “Hello World!”.
Boolean: A value or expression that evaluates to either true or false.
Literal: A Boolean, number or string that is written directly in the code. For example the expression 22/7*radius*radius contains 2 number literals.
Value: A number, Boolean, string or object.
We can define a variable like below:
var firstName="Shiva" (declaration and initialization at same place)
Please make note that use of semicolon is not mandatory. But it is good practice to use that as it is more readable.
Variables defined in such a way can contain any type of information: numbers, strings, Booleans (true and false), or objects.
sum=num1 + num2;
alert("The sum is: " + sum);
var num1: Integer
Now this variable could not be assigned value other than integer.
PI=22/7; //this code will not give any error, but value will not be changed
Statement is the basic item in any code. It tells computer to do something. Statements can be divided into five basic categories:
- Object manipulation
In the coming series we will learn more about above statements.