Identifiers:
1)JavaScript identifiers are names, which are given to variables, functions etc.
2)The names must start with a letter or underscore or $ symbol.
3)JS variable is case sensitive.
4)Name and name are two different variables.
5)Syntax: var variable_name=value.
6)Ex: var a=10;
2)The names must start with a letter or underscore or $ symbol.
3)JS variable is case sensitive.
4)Name and name are two different variables.
5)Syntax: var variable_name=value.
6)Ex: var a=10;
Literal
A literal is a possible values,which are given to variable.
1)Integer literals
Ex: 123(decimal value), 7b(hexadecimal value), 172(octal value).
2)Floating number literals
EX: 8.34, -4.2
3)Boolean literals
Ex: true,false
4)String literals
EX: "uma","100"
5)Object literals
EX: var userName= {
name : "uma"
};
6)Array literals
Ex: var names = ["uma","maheswari"];
Code:
Output:
Variables:
- Var is the keyword in JS to define variables.
- Variable can hold any type of value.
- Syntax: var var_name=value.
Code:
Output:
Expressions:
- An expression is a valid set of literals,variables,operators.
- Expression is used to evaluate a single value.
- Syntax:value=operand operator operand (or) operand=value.
- Ex:a=3+4, a=7.
Code:
Output:
Comments:
- Comments are used to explain the source code.
- // is used for single line comments.
- /* and */ are used for double line comments.
- Code which is in comments that won't execute.
Code:
Output:
JavaScript & Camel Case:
- JS is Case-sensitive.
- In JS, identifiers(variables & functions) should be in Camel Case
- We can use underscores but not '-'.
- We can use upper camel case. Ex: FirstName.
- We can use lower camel case. Ex: firstName.