6.13JS Lookup

Source: Internet
Author: User

Tag: Specify eve to define the join action ring will be EOF null

The Concat:concat () method is used to concatenate two or more arrays. The method does not alter the existing array, but only returns a copy of the concatenated array.

The Every:every () method tests whether all elements of the array pass the test of the specified function.
Find: If an element in the array satisfies the test condition, the Find () method returns the first element that satisfies the condition, and returns undefined if there are no elements that satisfy the condition.
The Indexof:indexof () method returns the first index value found in the array for the given element, otherwise returns-1.
The Foreach:foreach () method executes the supplied function (callback function) once for each element of the array.
Reverse: Function Reverses the character order in the string, to reverse the character order of the string returned by the value of string.
The Join:join () method joins all elements in the array into a single string.
The Pop:pop () method deletes the last element in an array and returns the element.
The Push:push () method adds one or more elements to the end of the array and returns the new length of the array (the Length property value).
The Shift:shift () method deletes the first element of the array and returns the element. The method changes the length of the array.
The Slice:slice () method will shallow copy (shallow copy) the part of the array into a new array and return the new array.
toLocaleString: This function is used as a string to return the current Date object time date has two, one is to the machine to see, is a row of numbers, the other is to allow people to understand the time format, then people look at this format is the local format. For local formats, each browser is rendered differently
The Splice:splice () method modifies the contents of an array by replacing the old element with a new element.
The Unshift:unshift () method adds one or more elements at the beginning of the array and returns the new length value of the array.


What do you mean prototypes?
In JavaScript, each time an object (function) is defined, the object contains some predefined properties. One of the properties of the function object is the prototype object prototype. Note: Normal objects do not have prototype, but have __proto__ properties.

The prototype object is actually an ordinary object (except for Function.prototype, which is a function object, but it is very special, he has no prototype attribute (previously said the function object has prototype property)). Look at the following example:
Function F1 () {};
Console.log (F1.prototype)//f1{}
Console.log (typeof F1. prototype)//object
Console.log (typeof Function.prototype)/Function, this special
Console.log (typeof Object.prototype)//Object
Console.log (typeof Function.prototype.prototype)//undefined

The output from this console.log (F1.prototype)//f1 {} shows that F1.prototype is an instance object of F1. When F1 is created, it creates an instance object of it and assigns it the prototype, the basic process is as follows:
var temp = new F1 ();
F1. Prototype = temp;

Therefore, function.prototype why the function object is solved, the above mentioned that all the new function () produced by the object is a function object, so Temp1 is a function object.
var temp1 = new Function ();
Function.prototype = Temp1;

What is the prototype object for? The primary function is for inheritance. Give examples:
var person = function (name) {
THIS.name = Name
};
Person.prototype.getName = function () {
return this.name;
}
var zjh = new Person (' Zhangjiahao ');
Zjh.getname (); Zhangjiahao

As can be seen from this example, by setting a property of a function object to Person.prototype, the normal object with the person instance (in the example: ZJH) Inherits this property. Specifically how to achieve the inheritance, it is necessary to talk about the following prototype chain.
Prototype chain
JS has a built-in property called __proto__ when creating an object (whether it is a normal object or a function object), and is used to point to the prototype object prototype of the function object that created it. Take the example above:

Console.log (zjh.__proto__ = = = Person.prototype)//true

Similarly, the Person.prototype object has the __proto__ property, which points to the prototype of the Function object (object) that created it.

Console.log (person.prototype.__proto__ = = = Object.prototype)//true

Continue, the Object.prototype object also has the __proto__ property, but it is more special, NULL

Console.log (object.prototype.__proto__)//null

6.13JS Lookup

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.