In Javascript scripts, the referenced parameters can be modified internally, but the references corresponding to the parameters cannot be modified. The following describes the reference principles of parameters in Javascript scripts: the referenced parameter can be modified internally (such as attributes), but the reference
Date typeThe date type in JavaScript is built on the Java.util.Date class in Java and uses UTC time to save the data to 285,616 years before or after January 1, 1970Create a Date object that uses the new keyword with a constructor declaration (the date object is also a reference type), and the new object automatically gets the current date and time without passing any arguments to the constructor, as follow
this series as effective JavaScript 's reading notes. Suppose you need a API used to traverse several elements, like this:var it = values (1, 4, 1, 4, 2, 1, 3, 5, 6); It.next (); 1it.next (); 4it.next (); 1The corresponding implementation can be:function values () {var i = 0, n = arguments.length;return {hasnext:function () {return I But the actual implementation is:var it = values (1, 4, 1, 4, 2, 1, 3, 5, 6); It.next (); Undefinedit.next (); Undefine
properties. The advantage of this is that each instance will have its own copy of the instance properties, while sharing the use of the method.
Disadvantages of prototype mode : For types that contain reference type properties, when each instantiated object is said, the comparison of the reference properties of each object will be perverted.
Person.prototype ={constructor:person, Name:"Nichola
JavaScript reference type-Function
The Function type is one of the ECMAScript reference types. It is a familiar Function. Interestingly, in ECMAScript, a function is actually an object.
Each Function is a Function-type instance and has attributes and methods like other reference types.
Because the function is an object
A reference type is a more complex type. In object-oriented programming, reference types are often used, which can be said to be the core of programming languages. There are several reference types built into JS, which are described below in one by one.Built-in reference typesObject type1, declaration method: Use the n
JavaScript reference PHP page data sheet does not refresh the new couple didn't give you a hand.
Query all
The information will be listed here ...
I use the buttons in the HTML to invoke the method in JavaScript, the PHP page in XMLHTTP is displayed in the following Div frame inside the PHP page content is to take out a table from the database.
If you want to associate a specified window, you can use the target attribute of the
The previous link opens a new window named review. The following links use JavaScript to produce the same effect:
Onclick = "window. Open ('HTTP: // www.intel.com/', 'review'); Return false"> intel
As you can see, it is very easy to assign a name to a new window. However, what if I name an existing window or a window generated by a user?
The name attribute of the
element of arr[i] in the hash array is undefined, the description is not duplicated, it is placed in a hash array } //after the loop is over, remove the hash array varback=[]; for(Back[back.length]inchhash); returnBack ; } console.log (F1 ([1,2,2,1,4,5])); Operating results: ["1", "2", "4", "5"]On the efficiency of execution, especially when the data increases, the hash array does not need to go through the array lookup, so the execution e
1. Array creation and initializationvar obj=new Array ();var arr=[];Can be extended to a certain length, the literal defines the array2. Stack by value Pass reference typeAn array is a reference type, not a value pass,Stack: Automatic allocation and release of the barrel, such as function parameters, local variables advanced after the first-level cacheHeap: Usually released by the programmer, the system rec
On the Internet for JS function parameter transfer way of opinions, here is also on the Internet to choose a better explanation:JS and Java are more similar, understand the Java parameter delivery way to understand JS is not difficult.If the value of a variable is an absolute basic type variable such as:function Add (num) { num+=10; return num; } Num=10; Alert (Add (num)); AELRT (num); // Output 20,10 This result should be meaningless to everyone, the value of the basic type vari
complete example of a reference to a JavaScript file:
The code is as follows
Copy Code
function wpjam_add_scripts () {Wp_register_script (' Plugin_script ', Plugins_url (' Plugin_script.js ', __file__), Array (' jquery '), ' 1.1 ', true);Wp_enqueue_script (' Plugin_script ');}Add_action (' wp_enqueue_scripts ', ' wpjam_add_scripts ');?>
Using Wp_enqueue_script to int
space, while B=a, b=3, the key is when a value changed to 5 after the value of B has not changed, this is because the data in the stack can be shared. If the execution of a=3,b=3;a=3 execution of 3 allocated memory, then b=3 will not be allocated in the stack memory storage 3 This value, but let B to point to the existing 3, when a=5, the program to find the stack there is no 5 this value, if there is a to point to 5, if not, then reallocate memory storage 5 , shown in the example above, a=5 re
JavaScript variable type
Value types: String, numeric, Boolean, Null, Undefined
Reference types: Arrays, objects, functions
Comparison of value type and reference type
Compare these two types through two instances (Debug environment: Chrome Developer Tool Console)
Value type instance
var a = ' Hello ';var B = A;b /* Hello * *A = ' world ';b /* Hello * *
Th
In JavaScript scripts, the reference principle of a parameter: the internal parameters of a reference, such as a property, can be modified, but the reference (reference) for the parameter cannot be modified.
A test example is as follows:
Copy Code code as follows:
Reading Table of Contents
Object type
1, through the constructor to create2. Creating objects by literal notation
Array type
The same array can also be created in two ways:If we want to print all the values in the array, we can print the variable name of the array directly:To add a value to an array:Stack method, queue method:About the ordering of arrays:Some ways to manipulate arrays:Find Location methodIterative methods
Merge method
Date type
RegExp type
function type
Three kinds of r
When variable A is assigned to variable B, the value in the stack is copied to the space allocated for the new variable.How to Understand?Copy codeThe Code is as follows:Var x = y = 1;Y = 2;Alert (x ); What is the value of x?Copy codeThe Code is as follows:Var obj = {};Var sub = {};Sub ['id'] = 3;Obj ['sub'] = sub;Sub ['id'] = 4;Alert (obj ['sub'] ['id']); What is the value of obj ['sub'] ['id? Are they really in line with your expectations?We run two pieces of code separately and found that the
Reference | objects | arrays
This article enumerates a variety of JavaScript objects and arrays, along with a brief description of the work done on each of these objects or arrays, and its associated property methods, as well as event handlers, which also indicate that the parent object of the object or array may also need to refer to the online The Super Text Object Hierarchy page (http://www.netscapepress
1. Object objectsCreate Object objects,var person = new Object (); var person = {Person.name = "Guoliang"; Name: "Guoliang",Person.age = 20; Age:20};In addition, the property name can also use a string, and the second belongs to the object literal representationAccess object properties can use the "." or "[]", which can only be accessed using "[]" when the property name contains non-alphabetic and non-numeric. It is generally recommended to use ".".2. Array typeThe array in
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.