From the course: JavaScript Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

JavaScript objects: The code version

JavaScript objects: The code version - JavaScript Tutorial

From the course: JavaScript Essential Training

Start my 1-month free trial

JavaScript objects: The code version

- To describe our real world objects, the backpack in JavaScript, we can use a JavaScript object. JavaScript objects are collections of data and functionality stored as properties and methods that describe the object and what it can do. To define an object, to create it, I first need a variable to hold the object. The modern convention here is to create a constant and we'll talk more about variables and constants later on in the course. So for now, just think of it as a box that we put the object inside. I give the constant the name, backpack, so we can refer back to it. So anytime we say backpack, we are now referring to the object. And then I use the equal symbol to assign a value to the constant, essentially filling the box. What I fill the box with is these two curly brackets. The curly brackets say this is a JavaScript object. And currently the JavaScript object is empty. So I need to populate my object with…

Contents