-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.js
More file actions
50 lines (40 loc) · 930 Bytes
/
Copy pathtemp.js
File metadata and controls
50 lines (40 loc) · 930 Bytes
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
// let obj = {
// name: 'jaydev kalariya',
// id: '38',
// };
// console.log(obj);
// let newobj = obj;
// newobj.id = '51';
// console.log(obj.id, ' ', newobj.id);
// //advantage of using spread operator it do deep copy
// let newobj2 = { ...obj };
// newobj2.id = '100';
// console.log(obj.id, ' ', newobj2.id);
// //REST
// const add = (arr) => {
// console.log(arr);
// };
// let x = [1, 2, 3];
// add(x);
// let arrr = [1, 2, 3];
// for (const [i, item] of arrr.entries()) {
// console.log(i, item);
// }
let person = {
name: 'jaydev kalariya',
id: '38',
color: 'green',
fun(namee) {
console.log(`${namee}'s favourite color is ${this.color}`);
},
};
let food = {
name: 'apple',
category: 'fruit',
color: 'yellow',
};
// person.fun();
let newfun = person.fun;
newfun('jaydev');
newfun.call(food, 'hello');
//call method is useful for giving reference to this variable for any new object.