1. Original value and reference valueThe values of the six simple data types are all primitive values. When a primitive value is assigned to another variable through a variable, a new value will be copied, and the two are independent of each other. let num1 = 5 let num2 = num1 When a reference value is assigned to another variable through a variable, a value is also copied. This value is actually a pointer (reference), and the pointer still points to the same object. let obj1 = new Object() let obj2 = obj1 Since they point to the same reference object, adding properties to obj1.name = "zhangsan" console.log(obj2.name) // zhangsan When passing parameters to a function, there is only one situation where the parameters are passed by value, which is the same as assigning a variable. However, with reference values, the value passed is a pointer, but the pointer still points to the same object. 2. instanceof console.log(1 instanceof Object) //false let obj = new Object(); console.log(obj instanceof Object) //true console.log(null instanceof Object) //false function fun(){ // } console.log(fun instanceof Object) //true console.log(fun instanceof Function) //true console.log([] instanceof Object) //true console.log([] instanceof Array) //true 3. Scope The scope of a variable is called a scope or execution context. A variable is no longer visible outside of the scope. All systems have a scope chain when searching for a variable. First, look for the variable in the closest block scope that references it. If it is not found, continue looking in the outer local scope. If it is not found again, look in the global scope. If it is not found, an error This is the end of this article about variables and scope in advanced JavaScript programming. For more information about JavaScript variables and scope, please search previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: TABLE tags (TAGS) detailed introduction
>>: Designing the experience: What’s on the button
First post the effect picture: A scroll bar appear...
1. How MySQL uses indexes Indexes are used to qui...
Compared with FTP, SSH-based sftp service has bet...
All content in this blog is licensed under Creati...
Table of contents 1. ChildNodes attribute travers...
Clustering is actually relative to the InnoDB dat...
Sometimes we want to implement such a function: c...
Table of contents Preface Problem: Large file cop...
Table of contents Intro Nginx Dockerfile New conf...
Table of contents 1. Component Introduction 2. Co...
An optimization solution when a single MYSQL serv...
Note: I use Centos to install docker Step 1: Inst...
1. Changes in MySQL's default storage engine ...
Table of contents What does the COUNT function do...
1. Introduction to KVM The abbreviation of kernel...