Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The process of incorporating keys and values into an object in Javascript is called "object literal notation." This involves creating an object using curly braces {} and separating the keys and values with a colon (:). Keys are always strings, but values can be any valid Javascript data type (e.g. strings, numbers, booleans, arrays, or even other objects). Here is an example of creating an object with two key/value pairs:

let person = {
  name: "John",
  age: 28
}

In this example, "name" and "age" are the keys, while "John" and 28 are the corresponding values. Once an object is created, you can access its properties using dot notation (e.g. person.name) or bracket notation (e.g. person["age"]).