Js basic note and js note

Source: Internet
Author: User

Js basic note and js note

Three-scope chain

1. the variables defined in the function are local variables and the layer of the scope chain. The scope chain is searched from the inside out. If it is found, the search is stopped.

2. It does not have its own block-level scope (it refers to the block of code closed by curly brackets), such as the if for statement.

3. variables declared without the keyword var are global variables. When the keyword var is used to declare a variable, the variable will be added to the latest scope.


3. Combined with constructor and prototype

Prototype attributes

In general, it allows all object instances to share its attributes and methods.

Constructor is used to define instance attributes. prototype is used to define shared attributes and methods.

Differences between basic and reference types

Basic Type: occupies a fixed amount of space in the memory, and their values are stored in the stack memory.

Reference Type: the object is copied to the newly assigned variable, but the pointer is copied, And the Pointer Points to the same object in the heap.


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.