before the website construction of JavaScript event object and code writing, we today to summarize the site construction of all the objects JS, event object refers to the DOM event object, and JS object scope is larger, Below we comprehensively summarize the website JS Object Classification summary and the difference.
I. What is a website JS object? What are the categories? What are the specific attributes?
In Font-family:-apple-system-font, "helvetica=" "sans=" "font-size:=" "1. Browser object: That is, the BOM, refers to the object model of the browser, its properties include browser open, close, size changes, Window movement and so on;
2. Web Document object: That is, the DOM, refers to the HTML page of the object model, his content and attributes include all the content on the page, elements and so on;
3. Event object, that is, DOM event, which belongs to the DOM Web Document object, the main properties include handle event, mouse keyboard event, etc.
4. Built-in objects: Refers to some of JavaScript's most basic methods of functional objects, including numeric objects, string objects, array objects, and Date function objects, and so on; Two. Can JS customize the object in website construction? What are the methods?
JS is a customizable object, there are two ways to do it:
1. Define and create objects directly, and the code demonstrates the following:
People=new object (); Here a new object is created with the keyword new;
People.name= "Xiaoming"; Set properties by using the object. Custom keywords;
Deocument.write ("Name:" +people.name+ ";") Print out objects by document
2. Define and create the object through the function, with the following code:
function people (Name,age) {
This._name=name; Use this to index
This._age=age;
}
Son=new people ("xiaoming", 18)
document.write ("Name:" +son._name+ ", Age:" +son_age)
The above content is about the summary of JS object classification and how to customize the object, this article by Gongyi website production-Gongyi full stack network studio provided.
JavaScript Object Classification Summary and method of creation