Data Types:
1. String - Sequence of characters. e.g. var x= "i love javascript" or var x='i love javascript'
2. Number - 6, 8.0. JavaScript uses floating points to represent numbers. e.g. var n=9.08
Range: When decimal point is defined: -2e53 to 2e53. When decimal point is defined: -2e31 to 2e31
3. Boolean - true or false. e.g. var happy = true
4. undefined - default value assigned to any variable. e.g.
var grace;
console.log(grace); //output will be undefined
5. null - value assigned to a variable by programmer.
e.g. var frost = "snowy evening";
var frost=null;
console.log(frost); //outputs null.
Pattern Matching
---------------------
string has a 'match' function which takes 'pattern' as argument.
pattern can be defined in either of the 2 ways:
A. var patt= /woods/;
B. var patt = new RegExp('woods');
Lets see a complete example:
var phrase = "whose woods these are, i think i know";
phrase.match(patt);
1. String - Sequence of characters. e.g. var x= "i love javascript" or var x='i love javascript'
2. Number - 6, 8.0. JavaScript uses floating points to represent numbers. e.g. var n=9.08
Range: When decimal point is defined: -2e53 to 2e53. When decimal point is defined: -2e31 to 2e31
3. Boolean - true or false. e.g. var happy = true
4. undefined - default value assigned to any variable. e.g.
var grace;
console.log(grace); //output will be undefined
5. null - value assigned to a variable by programmer.
e.g. var frost = "snowy evening";
var frost=null;
console.log(frost); //outputs null.
Pattern Matching
---------------------
string has a 'match' function which takes 'pattern' as argument.
pattern can be defined in either of the 2 ways:
A. var patt= /woods/;
B. var patt = new RegExp('woods');
Lets see a complete example:
var phrase = "whose woods these are, i think i know";
phrase.match(patt);
No comments:
Post a Comment