[JS]JS stack memory Global/private scope, code pre-interpretation

Source: Internet
Author: User
How the JS code executes

Browser provides execution environment: global scope (provide JS execution environment, stack memory)------------to perform JS pre-interpretation

- 带var            : 提前声明- 带function关键字的: 提前声明+定义

Stack memory (corresponding to global/private scope) and heap memory in JS

<script>    // 基本: num str boollen null undefied    // 引用: [] {} \^$\ Date    var num = 12;    var obj = {name: "maotai", age: 22};    function fn() {        console.log("hello world")    }    /*    1.浏览器提供执行环境: 全局作用域(提供js执行环境, 栈内存)    2.执行js时候,需要预解释      2.1声明+定义      2.2预解释:        - 带var            : 提前声明        - 带function关键字的: 提前声明+定义    3.    栈内存: 提供供js代码执行的环境,作用域(全局和私有)    堆内存: 用来存储引用数据类型的值. 对象存储的是属性名和属性值,函数存储的是代码字符串.    全局作用域:    私有作用域    */</script>
Hands-on memory map can feel the above said

[JS]JS stack memory Global/private scope, code pre-interpretation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.