Think you might be in the wrong place? Go home!
Think of an object as a digital container that holds related information about something. It’s like a collection of attributes, much like a book having a title, author, and pages.
Use bracket notation when property names have special characters, spaces, or when using variables for dynamic access.
const dog = {
name: 'Spot',
age: 2,
color: 'white with black spots',
humanAge: function (){
console.log(`${this.name} is ${this.age*7} in human years`);
}
}
this refers to the object to which the method belongs, which is the dog object. The use of this allows you to access and manipulate the object’s properties and methods from within the object itself. It refers to the current instance, making the code flexible and reusable.
The DOM (Document Object Model) is a way to represent the structure of a web page.
JavaScript can interact with and modify this structure, making web pages dynamic and interactive.
Information gathered using ChatGPT