And object is a packet of data (and, optionally, functionality) that has properties in the form of key:value pairs. For example, a car could be like an object in that it has a property of the color red and another property that is the manufacturer Toyota. This would be written out in JavaScript as:
let car = { color: red, manufacturer: Toyota}
It’s most efficient when you’re working with a single object
It is easier to work with than an array, when you want to identify individual items by name
Objects are unordered, the properties don’t have indices.
They also have a key:value pair, where arrays have an index:value, where the index is always the order of the array (starting at 0)
You would need to use bracket notation if an object property name is held in a variable, then you can’t use dot notation to access the value, but you can access the value using bracket notation.
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 current object the code is being written inside. The advantage to using “this” is that you can use the same method definition for each object that you create.
The DOM is the Document Object Model. It is how the objects that make up the content and structure of a document are represented.
The DOM (Document Object Model) and JavaScript are two crucial parts of making a web site. The DOM is like a map of a web page’s structure, where each element (like text, images, buttons) is represented as objects that can be manipulated.
JavaScript is one of many the programming languages that allows you to interact with this map (the DOM). You can use JavaScript to change the content, style, and behavior of a web page by accessing and modifying these DOM objects. JavaScript and the DOM work together to make web pages interactive and responsive.
How are elements in HTML object?
“this”???