-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
137 lines (137 loc) · 3.03 KB
/
script.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Object declare using {} and print using dot notation
// var person ={
// name: "Rajini",
// age: 45,
// occupation: "actor"
// }
// console.log(person.name);
// console.log(person.age);
// console.log(person.occupation);
// Object declare using {} and print using square []
// var person ={
// name: "Rajini",
// age: 45,
// occupation: "actor"
// }
// console.log(person["name"]);
// console.log(person["age"]);
// console.log(person["occupation"]);
// console.log(person)
// Object declare using new method
// var person = new Object();
// person.name = "rajini";
// person.age = 45;
// person.occupation = "actor";
// person.city = "Chennai";
// console.log(person);
//Modifying the Object using dot
// var person = {
// name: "rajini",
// age: 45
// }
// console.log(person)
// person.name= "kamal"
// console.log(person);
//Modifying the Object using square[]
// var person = {
// name: "rajini",
// age: 45
// }
// console.log(person);
// person["age"]=60;
// console.log(person);
//Adding a new property
// var person = {
// name:"kamal",
// age:60
// }
// console.log(person)
// person.occupation= "actor"
// console.log(person);
//Removing Obj property
// var person = {
// name:"kamal",
// age:60,
// city: "chennai"
// }
// console.log(person);
// delete person.city
// console.log(person);
//JSON.parse()
// var a = '{"name":"kamal","age":60}';
// console.log(a);
// var b = JSON.parse(a);
// console.log(b);
//JSON.stringify
// const c = {
// name: "kamal",
// age: 60
// }
// console.log(c)
// var d = JSON.stringify(c);
// console.log(typeof(d))
//Nested JSON object
// var person = {
// "name":"kamal",
// "age" :60,
// "occupation":"actor",
// "address": {
// "city" : "chennai",
// "pincode" : 60001
// }
// }
// console.log(person)
//Array Destructuring
// const arr = [1,2,3];
// const[x,z,wwww,d=4]= arr;
// console.log(x);
// console.log(z);
// console.log(wwww);
// console.log(d);
// console.log(arr);
//Object Destructuring
// const obj = {
// name: "kamal",
// age:60,
// address:{
// city: "chennai",
// pin: 60001
// }
// }
// //const{key}=objectname
// const {name,age}= obj;
// console.log(name);
// console.log(age);
//Use Strict in Js
//without strict mode
// fullname = "kamal"
// console.log(fullname)
//with strict mode
// 'use strict';
// fullname = "kamal"
// console.log(fullname)
//1. Using "this" keyword alone, refers to global object
// console.log(this);
//2.In regular function , refers to global object
// const a = function(){
// console.log("hello world");
// console.log(this)
// }
// a();
//3. In a function in strict mode , "this" is undefined.
// 'use strict';
// const a = function(){
// console.log("Nandu");
// console.log(this)
// }
// a();
//4. In a method, "this" refers to the owner object.
const person = {
names : "ReshmaPriya",
age: 60,
occupation: "actor",
detail: function(){
console.log(`I love ❤ ${this.names}`)
}
}
console.log(person.detail());