, you can use the keyword "this" to reference a global object. However, you do not need to reference a global object in this way, because the global object is the header of the scope chain, which means that all non-restrictive variables and function names will be queried as attributes of the object. For example, when JavaScript code references the parseint () fun
The question of passing values by value or by reference in JavaScript is discussed.
Recently I encountered an interesting question: "Is the value in JS passed by value or by reference ?"Before analyzing this problem, we need to know what is call by value and call by reference ). In computer science, this part is called
This
This is a keyword for JavaScript, and the value of this is changed as the function is used differently. But there is always a principle, that is, this refers to the object that calls the function.
I. Definition
1, this is a special object (or this reference) inside the function-it refers to the environment object to which the function is executed.
2. This refer
using values, and reference data uses references to manipulate data. The different ways of operation, the results produced by nature are also different. Let's look at one more example:
var s = "abc"; String, value type data
var o = new string (s); String object, boxed string
function f (v) { //op function
v.tostring = function () { ///Modify Parameters Method ToString () return
123 ;
};
}
f (s); Incom
still 10;Below, the two Boolean variables bl and BL1 are also basic data types, and the same holds two different base data type values, BL1 saves a copy of the BL copy.Demonstrates the process of assigning this basic data type:Here's a look at reference type data:The JavaScript reference data type is an object stored in the heap memory, and unlike other language
Tips: This article is after listening to the four-foot cat JS course after the search, in-depth understanding can see two blog: JavaScript data types-value types and reference types JavaScript data manipulation-the nature of primitive and reference valuesIn the traditional sense,
"false" and "true. However, in this line of code, ofalseobject is calculated, not its value.False.
As discussed earlier, in a Boolean expression, all objects are automatically converted to true, so the value of ofalseobject is true. Then, true and true are used to perform the and operation. The result is true.
Note: although you should understand the availability of Boolean objects, it is best to use the original Boolean value to avoid the problems mentioned in this section.See
For more informa
There are two types of data in JavaScript: base type and reference type.
The basic type is simply a simple data segment.
A reference type is an object that consists of multiple values.
When we do an assignment, the parser first parses whether the data is a value type or a reference type.
Two ways of accessing:
Bas
The ECMAScript variable contains values of two different data types: the base type value and the reference type value. The base type value is a simple data segment, whereas a reference type value refers to objects that may be composed of multiple values.
When assigning a value to a variable, the parser must determine whether the value is a base type or a reference
Memory leaksIn JavaScript, we seldom pay attention to memory management. We create variables, use variables, and browsers look at these underlying details as normal.But when the application becomes more complex and Ajax, or the user stays on a page for too long, we may need to pay attention to some problems, such as a browser that spends more than 1G of memory, and is constantly increasing. These problems are often caused by memory leaks.Javascript me
The ECMAScript variable may contain values for two different data types: the base type value and the reference type value. A primitive type value refers to a simple data segment, whereas a reference type value refers to an object that may consist of multiple values.When assigning a value to a variable, the parser must determine whether the value is a base type value or a
This article will share with you the object and array reference types in my javascript advanced programming learning notes, involving knowledge about javascript reference types, if you are interested in the javascript reference ty
] Or this [0, that is, the index method must be used for reference. If the index method is not used, the index method must be used for reference.
3. Define object Methods
1) JavaScript can define three types of methods for objects: Private methods, instance methods, and class methods, similar to Java:Private methods can only be used inside objectsThe instance met
Su-MO OrangeLinks: https://www.zhihu.com/question/27114726/answer/35481766Source: KnowCopyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.Before the first time to see this part of the time is also a bit foggy, today saw the subject asked this question and carefully looked again, consulted the relevant information, now is more clear.Combine your own understanding to sort it out.Because to be completely c
, start, Len) {
/* Complete function * *
}
This is a linked list problem written in JavaScript. Because a linked list has a more complex reference operation, it can be used to examine the understanding of JavaScript references. Comes with simple test cases:
Copy Code code as follows:
/* Test dcatenate and sublist functions are correct * *
Memory leaksIn JavaScript, we have very little attention to memory management.We create variables, use variables, and browsers look at these underlying details as normal.But when applications become more complex and Ajax-or users stay on a page for too long-we may need to pay attention to some issues. such as a browser to spend more than 1G of memory, and is constantly added.These problems are often caused by memory leaks.Javascript memory leaksThe co
Description of reference types of basic javascript data types and value types
I. Basic Data Types
In javascript, the keywords used to declare variables are var. This is different from other programming languages, but javascript also contains five basic data types (simple data types ), they are: Undefined, Null, Boolean
JavaScript basic Data type:JS basic data types include: Undefined,null,number,boolean,string. The base data type is accessed by value, which means that we can manipulate the actual values that are saved in the variable. 1. The value of the base data type is immutableNo method can change the value of a primitive type, such as a string:var name = "Change"; Name.substr ();//hangconsole.log (name);//changevar s = "Hello"; s.touppercase ()//hello; Console
First, let's take a look at a javascript interview question.Source code(I made a small change). This example is used to understand the reference type in JavaScript. Then we made a preliminary study on the objects in JavaScript.
1:VaR A = {X: 1 };
2:VaR test = function (OBJ)
3:{
4:OBJ. x = 2;
5:Console. Log ("
The ECMAScript variable contains values of two different data types: the base type value and the reference type value. The base type value is a simple data segment, whereas a reference type value refers to objects that may be composed of multiple values.
When assigning a value to a variable, the parser must determine whether the value is a base type or a reference
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.