-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_objects.js
More file actions
41 lines (30 loc) · 1010 Bytes
/
03_objects.js
File metadata and controls
41 lines (30 loc) · 1010 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
// singleton
// object literals
// Object.create
const mySym = Symbol("key1"); //symbol
const jsUser = {
name: "sandeep",
"full name": "sandeep dhanger",
[mySym]: "mykey1",
age: 20,
location: "Indore",
email: "sandeep@gmail.com",
isLoggedIn: false,
lastLoginDays: ["Monday", "Saturday"]
}
// console.log(jsUser.email);
// console.log(jsUser["email"]);
// console.log(jsUser["full name"]);
// console.log(jsUser[mySym]); // to excess the symbol value by using this snytax
jsUser.email = "sandeep@yahoo.com"; // change the object key
// Object.freeze(jsUser); // after freeze the object no changes propogate
jsUser.email = "sandeep@facbook.com"
//console.log(jsUser);
jsUser.greeting = function() {
console.log("Hello js user");
}
console.log(jsUser.greeting());
jsUser.greetingTwo = function() {
console.log(`Hello js user, ${this.name}`);
}
console.log(jsUser.greetingTwo());