-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects.js
More file actions
39 lines (21 loc) · 986 Bytes
/
Copy pathobjects.js
File metadata and controls
39 lines (21 loc) · 986 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
//Non primitive datatypes are always returened as objects in JavaScript. Objects are mutable and are stored as reference types. When we assign an object to a variable, we are actually assigning a reference to that object in memory. This means that if we change the object through one variable, it will affect all variables that reference that same objecta.
const studentDetails = {
id : 1,
name : "Jibin",
age : 40,
}
console.log(studentDetails);
console.log(typeof(studentDetails));
console.log(studentDetails.name);
console.log(studentDetails['age']);
//To add a additional object
studentDetails.grade = "A";
console.log(studentDetails);
//To update the existing object grade to A+
studentDetails['grade'] = "A+";
console.log(studentDetails);
studentDetails['age'] = 41;
console.log(studentDetails);
// if a new variable is created without var/let at a later stage of the code, it will violate the strict mode rule.
//-------------------------
// Arrays