-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjects.js
More file actions
43 lines (31 loc) · 933 Bytes
/
Objects.js
File metadata and controls
43 lines (31 loc) · 933 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
//singleton object
//create.object (constructor method(object creation))
//object literals
const mySym = Symbol(" key1")
const JsUser = {
name: "Rutuja",
mySym: "key1",
email_id: "rutujakolte193@gmail.com",
age: 22,
location: "Pune",
isLoggedIn: false,
lastLoginDays: ["Monday", "Wednesday"]
}
console.log(JsUser.email_id)
console.log(JsUser["email_id"])
console.log(JsUser.age)
console.log(JsUser["mySym"])
console.log(JsUser[mySym])
//there is another datatype Symbol interviewr's ask add symbols to keys and print it
JsUser.email_id = "rutujakolte193@gmail.com"
//Object.freeze(JsUser)
JsUser.email_id = "rutujakolte193@gmail.com"
console.log(JsUser["email_id"]);
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());