Front-end development - BOM

0. GOOD vs. SUN

  • BOM: Browser Object Model, the browser object model, is the absolute core of using JavaScript in the web;
    • BOM: Provides an object that interacts with the browser window independently of its content.
    • The BOM provides many objects (window, location, navigator) for accessing browser functions that are not related to any web page content;
  • DOM: Document Object Model, DOM is a tree-based API for XML. It describes the methods and interfaces for processing web content. It is an API of HTML and XML. DOM plans the entire page into a document composed of node levels. The DOM itself is a language-agnostic API, it's not tied to Java, JavaScript, or other languages.

1. window object

  • Global scope:

    • The window object also plays the role of the Global object in ECMAScript, so all variables and functions declared in the global scope will become the properties and methods of the window object.
    var age = 26
    function showAge() {
        alert(this.age)
    }
    
    // 访问全局作用域里的变量
    alert(window.age)
    //
    showAge()
    // 访问全局作用域中的函数
    window.showAge()

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325365280&siteId=291194637