This Repo required for Asac labs class 2
Objects group together a set of variables and functions to create a model of a something you would recognize from the real world. In an object, variables and functions take on new names.
You access the properties of an object with a simple dot-notation:
objectName.propertyName
;
Programmers use a lot of name/value pairs:
Literal notation is the easiest and most popular way to create objects. (There are several ways to create objects.)
The Object literal notation is basically an array of key:value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last, just like a regular array. Values created with anonymous functions are methods of your object. Simple values are properties.
var myObject ={
myProperty : value,
yourProperty : value,
myMethod : function(){
//code here
},
yourMethod : function(){
//more code
}
} ### “this” in methods: To access the object, a method can use the this keyword. The value of this is the object “before dot”, the one used to call the method.
const test = {
prop: 42,
func: function() {
return this.prop;
},
};
console.log(test.func());
output: 42
you can a proparity of an object using:
The Document Object Model (DOM) specifies how browsers should create a model of an HTML page and how JavaScript can access and update the contents of a web page while it is in the browser window.
The dom tree is a model of a web page as a browser As a browser loads a web page, it creates a model of that page. The model is called a DOM tree, and it is stored in the browsers’ memory. It consists of four main types of nodes :
You can get element from the the method by get element you can also loop over nodelist and apply the same statement to each .TRAVERSING THE DOM When you have an element node, you can select another element in relation to it using these five properties. This is known as traversing the DOM.
The opening tags of HTML elements can carry attributes and these are represented by attribute nodes in the DOM tree.
Once you have accessed an element node, you can then reach the text within that element. This is stored in its own text node.
DOCUMENT OBJECT MODEL