Object Properties in JavaScript

Level 276 keystrokes

Creates an object with properties and accesses them using dot notation.

JavaScript code

// Create an object using curly braces {}
// Objects contain key-value pairs called properties
1let car = {
// brand is a property with string value "Toyota"
2 brand: "Toyota",
// year is a property with number value 2020
3 year: 2020
4};
// Access properties using dot notation (object.property); prints "Toyota 2020"
5console.log(car.brand, car.year);

Output

Toyota 2020
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • .× 3
  • ,× 2
  • ;× 2
  • :× 2
  • "× 2
  • (× 1
  • )× 1
  • {× 1
  • }× 1
  • =× 1

More JavaScript examples at level 2

← JavaScript typing practice