Skip to content

Latest commit

History

History
29 lines (28 loc) 路 847 Bytes

File metadata and controls

29 lines (28 loc) 路 847 Bytes

Object

Object is a real world entity with certain properties. It is a collection of key-value pairs that specify the object.

let person = {
    name: "Rohan",
    age: 22
};
// Here, person is an object with two properties, name and age which specifies that person.

馃摓 Accessing properties

Accessing the object properties is possible in two methods:

  • Dot notation
  • Bracket notation
console.log(person.name);// Dot notation
console.log(person["age"]);// Bracket notation

Note

If the property to be accessed is determined during run-time, using dot notation won't do the job.

let selection = "name";
console.log(person.selection);// This doesn't work
console.log(person[selection]);// This works

previous

next