JS Object Basics Intro to the DOM
Understanding the problem domain is the hardest part of programming What’s the difference between primitive values and object references in JS
An object is something that has properties. Everything has properties like a book. Properties are things like, colour, design, weight, title, material. Every BOOK object will have these same properties.
they are a way to define and create objects using concise syntax (object initializers). This can improve an objects flexibility and reusability and ease Data Manipulation.
data is stored in key-value pairs within objects unlike arrays where it’s single values.
We use bracket notation when we want to acces an object’s property, when the property name needs to be dynamically determines or when property name includes special characters or spaces. bracket notation is used, allowing us to access the properties by providing the property name as a string enclosed in square brackets. Dot notation to access the properties would result in an error.
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 dog object eg it will grab dog.name = “Spot”
DOM stands for Document Object Model and is a programming interface for web documents which represents the page.
The DOM is not part of the JavaScript language, but is instead a Web API used to build websites. You can access the DOM though JS and use JS to manipulate the DOM