-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray-object-operator.js
113 lines (61 loc) · 2.19 KB
/
array-object-operator.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//1.Member Access(.)
//syntax
//Object.Property;
//example
/*
let obj ={id:"i", name:"java"};
console.log(obj.name);
//example
console.log(obj["name"]);
*/
//2. in operator
//example
/*const car ={name:"audi", model:"one", year:2052};
console.log("name" in car);*/
//prints true
//3. Operator New
//use to create instance of the model class
//example
/*
class Model{
constructor(){
};
};
//creating an instance of the model class:-
const c1 =new Model();
//creating instance
const c2 =new Model();*/
//4.instanceof operator
//*considers left side as object and right side as class object i.e left side is the instance of the right side.
//example
/*
const d =new Date();
console.log(d instanceof Date); //prints true
//declare array
const arry =[1,2,3];
console.log(arry instanceof Array);
//but
console.log(arry instanceof Date);*/
//prints false
//5. delete operator
//example
/*
const obj ={x:1, v:2, g:3};
console.log('x' in obj); //prints true
//delete object:-
delete obj.x;
console.log('x' in obj); //prints false
//using array
const arry =[1,2,3,4];
console.log(arry[3]); //prints 4
//delete element:-
delete arry[3];
console.log(arry[3]); //prints undefined
*/
//6. conditional operator(? :)
//example
/*
let print ="good morning to all";
print =print ? print:"welcome boizz"; //if expression return true then we will print "good morning to all" else print "welcome boizz".
console.log(print);
*/