-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (63 loc) · 1.91 KB
/
index.js
File metadata and controls
69 lines (63 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var one = 1; //number type
var two = '2'; // string type
var three = 'three'; //string type
var four = ["Saab", "Volvo", "BMW", "NANO"]; //array object type
/*
variable "five" is object which contains key-value
syntax is (KEY:VALUE)
*/
var five = {
one : 1,
two : 2,
three: 3,
four : 4,
five : 5
};
//defining functions
// function six() {
// console.log('six is function.');
// }
//other way to define functions
var six = function() {
console.log('six function.');
};
var seven = new Number(12);
var eight = new String('Eight');
var nine = new Array("Saab", "Volvo", "BMW");
//typeof tutesnode
// console.log(1, typeof one);
// console.log(2, typeof two);
// console.log(3, typeof three);
// console.log(4, typeof four);
// console.log(5, typeof five);
// console.log(6, typeof six);
// console.log(7, typeof seven, seven);
// console.log(8, typeof eight, eight);
// console.log(9, typeof nine, nine);
// console.log('null', typeof null);
// console.log('undefined', typeof undefined);
// console.log('NaN', typeof NaN);
/*output of above code
1 'number'
2 'string'
3 'string'
4 'object'
5 'object'
6 'function'
7 'object' [Number: 12]
8 'object' [String: 'Eight']
9 'object' [ 'Saab', 'Volvo', 'BMW' ]
null object
undefined undefined
NaN number
*/
//-------------------------------------------------------------------------------
//JSON tutes
console.log(five); // it will print{ one: 1, two: 2, three: 3, four: 4, five: 5 }
console.log(five.one);//way to access keyvalue of object "five"
console.log(five['one']);//other way to access keyvalue of object "five"
five.six = 6; //adding new key to object "five"
// five["six"] = 6;//other way for adding new key to object "five"
console.log(five);//output-{ one: 1, two: 2, three: 3, four: 4, five: 5, six: 6 }
delete five.two; // deleting any key of object
console.log(five);//output-{ one: 1, three: 3, four: 4, five: 5, six: 6 }