Native JS object-related API collections

Source: Internet
Author: User
Tags first string natural logarithm square root

Object objects Generate Instance objects
var o = new Object ()
Property
Object.prototype //Return prototype object
Method
Object.keys (o) //Iterate over an object's enumerable properties object.getownpropertyname (o) //Traversal object non-enumerable properties
Methods for object instances
ValueOf //returns the value corresponding to the current object. toString //returns the string form corresponding to the current object. tolocalestring //Returns the local string form corresponding to the current object. hasOwnProperty //Determines whether a property is a property of the current object itself, or a property inherited from a prototype object. isprototypeof //Determines whether the current object is a prototype of another object. propertyisenumerable //Determines whether a property can be enumerated.
Array object Generation Instance Object
var a = new Array ()
Property
A.length //Length
Array.isarray ()
Array.isarray (a) //To determine whether a value is an array
Methods for array instances
A.valueof ()//Returns the array itselfA.tostring ()//Returns the string form of the arrayA.push (Value,vlaue ...)//used to add one or more elements at the end of the array and returns the length of the array after adding the new element. Pop ()//Used to delete the last element of the array and return the elementJoin ()//Use a parameter as a delimiter to return all array members to a string. If no arguments are supplied, the default is separated by commas. Concat ()//For merging multiple arrays. It adds the members of the new array to the end of the original array, and then returns a new array, unchanged from the original array. Shift ()//Used to delete the first element of the array and return the element. Unshift (value)//used to add an element at the first position in the array and returns the length of the array after adding the new element. Reverse ()//used to reverse the order of the elements in the array, returning the changed arraySlice (Start_index, upto_index);//Used to extract part of the original array, return a new array, and the original array is unchanged. The first argument is the starting position (starting at 0), and the second parameter is the terminating position (but the element itself is not included in the position). If the second argument is omitted, it is returned to the last member of the original array. A negative number indicates the penultimate part. Splice (index, Count_to_remove, AddElement1, AddElement2, ...);//Used to delete a member of the original array, and can be added to the new array member at the deleted location, and the return value is the element that was deleted. The first parameter is the starting position of the deletion, and the second parameter is the number of elements to be deleted. If there are more arguments later, it means that these are the new elements to be inserted into the array. Sort ()//array members are sorted by default in dictionary order. After sorting, the original array will be changed. If you want the sort method to be sorted in a custom way, you can pass in a function as a parameter, which means sorting by custom method. The function itself accepts two parameters, representing two elements for comparison. If the return value is greater than 0, the first element is ranked after the second element, and in other cases, the first element is preceded by the second element. Map ()all members of the array call a function in turn, returning a new array based on the result of the function. Map (Elem,index,arr)The //map method accepts a function as a parameter. When the function is called, the map method passes it to three parameters, namely the current member, the current position, and the array itself. ForEach ()//Iterate through all the members of an array, perform an operation, and the parameter is a function. It accepts three parameters, the value of the current position, the number of the current position, and the entire array. Filter ()The //parameter is a function in which all array members execute the function sequentially, returning a new array of members that return a result of true. The method does not change the original array. Some ()//used to determine if an array member conforms to a certain condition. Takes a function as an argument, and all the array members execute the function sequentially, returning a Boolean value. The function takes three parameters, in order, the member of the current position, the ordinal of the current position, and the entire array. As long as the return value of an array member is true, the return value of the entire some method is true, otherwise false. Every ()//used to determine if an array member conforms to a certain condition. Takes a function as an argument, and all the array members execute the function sequentially, returning a Boolean value. The function takes three parameters, in order, the member of the current position, the ordinal of the current position, and the entire array. The return value of all array members is true to return true, otherwise false. Reduce ()each member of the array is processed sequentially, and eventually accumulates as a value. Left-to-right processing (from the first member to the last member)Reduceright ()each member of the array is processed sequentially, and eventually accumulates as a value. Right to left (from the last member to the first member)IndexOf (s)Returns the position of the first occurrence of the given element in the array, or 1 if it does not appear. Can accept the second parameter, which indicates where the search beginsLastIndexOf ()Returns the position of the last occurrence of the given element in the array, or 1 if it does not appear.
Number Object Generation Object
var n = New number ()
The property of the Number object
number.positive_infinity //positive infinity, pointing to INFINITY. number.negative_infinity //negative infinity, pointing to-infinity. Number.NaN //Represents a non-numeric value, pointing to NaN. Number.MAX_VALUE //Indicates the maximum positive number, corresponding to the minimum negative number is-number.max_value. Number.min_value //Represents the smallest positive number (that is, the positive number closest to 0, 5e-324 in the 64-bit floating-point system), and the corresponding negative number closest to 0 is-number.min_value. Number.max_safe_integer //Represents the largest integer that can be represented accurately, that is, 9007199254740991. Number.min_safe_integer //Represents the smallest integer that can be represented accurately, i.e.-9007199254740991.
Method of the Number object instance
ToString () //is used to convert a numeric value to a string. You can accept a parameter that represents the output's binary. If this argument is omitted, the value is first converted to decimal, and then the string is output, otherwise a number is converted into a string of characters based on the input specified by the parameter. toFixed () //is used to convert a number to a specified number of decimal places, and returns the string corresponding to that decimal. toexponential () ///used to convert a number to a scientific notation form. You can pass in a parameter that represents the number of digits of a valid digit after the decimal point, ranging from 0 to 20, beyond which a rangeerror is thrown. toprecision () ///For a valid number to convert a number to a specified number of digits.
String Object Generation Instance Object
var s = new String ()
Properties of the String object
S.length //Returns the length of the string
Method
S.chatat (Index)//Returns the character at the specified positionS.fromcharcode ()//The parameter of the method is a series of Unicode code points that return the corresponding string. S.charcodeat (Index)//Returns the Unicode code point for the given position character (in decimal notation)S.concat (S2)//For connection of two stringsS.slice (Start,end)//Used to remove substrings from the original string and return without changing the original string. The first argument is the starting position of the substring, and the second argument is the end of the substring (without that position). If the argument is a negative value, it represents the position at which the inverse is calculated from the end, that is, the negative value plus the string length. S.substring (Start,end)//Used to remove substrings from the original string and return without changing the original string. The first parameter represents the start position of the substring, and the second position represents the end position. S.substr (Start,length)//Used to remove substrings from the original string and return without changing the original string. The first argument is the starting position of the substring, and the second argument is the length of the substring. If the first parameter is a negative number, the character position of the reciprocal calculation is indicated. If the second argument is a negative number, it is automatically converted to 0, so an empty string is returned. S.indexof (s)Returns the position of the first occurrence of the given element in the string, or 1 if it does not appear. Can accept the second parameter, which indicates where the search beginsS.lastindexof ()Returns the position of the last occurrence of the given element in the string, or 1 if it does not appear. S.trim ()//To remove spaces at both ends of the string, returning a new stringS.tolowercase ()//used to convert a string to lowercase, returning a new string without changing the original string. S.touppercase ()//Full capitalizationS.localecompare (S2)//For comparison of two strings. It returns an integer, if less than 0, that indicates that the first string is less than the second string, and if it is equal to 0, the value is equal, or greater than 0, indicating that the first string is greater than the second string. S.match (RegExp)//used to determine whether the original string matches a substring, returns an array, and the member is the first string to match. If no match is found, NULL is returned. S.search ()The //return value is the first position to match. If no match is found, 1 is returned. S.replace (Oldvalue,newvalue)//used to replace matched substrings, typically only the first match is replaced (unless a regular expression with the G modifier is used). S.split ()//Splits a string by a given rule, returning an array of separated substrings. You can also pass in the second parameter, which determines the number of members that return the array.
Math Object Properties
MATH.E //constant E. Natural logarithm of MATH.LN2//2. Natural logarithm of math.ln10//10. math.log2e //logarithm of E of base 2. math.log10e //logarithm of E of base 10. Math.PI //constant PI. square root of math.sqrt1_2//0.5. square root of Math.sqrt2//2.
Mathematical Methods
Math.Abs () //Returns the absolute value of the parameter Math.ceil () //Rounding up, takes a parameter, returns the smallest integer greater than the parameter. Math.floor () //down roundingMath.max (n,n1,...) //can accept multiple parameters, return maximum value math.min (n,n1,..) //can accept multiple parameters, return the minimum value Math.pow (n,e) ///exponential operation, returns an exponential value with the first argument as the base and the second argument to a power. math.sqrt () //returns the square root of the parameter value. If the argument is a negative value, Nan is returned. Math.log () //returns the natural pair of values with E as the base. math.exp () //Returns the exponent of E, which is the parameter of constant E. Math.Round () //Rounding math.random () //Returns a pseudo-random number from 0 to 1, which may be equal to 0, but must be less than 1.
Trigonometric methods
Math.sin () //Returns the sine of the parameter Math.Cos () //Returns the cosine of the parameter Math.tan () //return tangent of parameter math.asin () //Returns the inverse of the parameter (radian value) Math.acos () //Returns the inverse cosine (radian value) of the parameter Math.atan () //Returns the inverse tangent (radian value) of the parameter
JSON Object Methods
json.stringify () //used to convert a value to a string. The string should be in JSON format and can be restored by the Json.parse method. //(Json.stringify (obj, selectedproperties)) can also accept an array as the second parameter, specifying the properties that need to be converted to a string. ///You can also accept the third parameter to increase the readability of the returned JSON string. If it is a number, the space (up to 10) is added before each property, and if it is a string (no more than 10 characters), the string is added in front of each line. json.parse () //is used to convert a JSON string into an object.
Console Object Methods
Console.log (text,text2,...) //used to output information in the console window. It can accept multiple parameters and concatenate their results to output. If the first argument is a format string (using a format placeholder), the Console.log method replaces the placeholder with the following parameter, and then outputs it. console.info () ///output information in the console window, plus a blue icon in front of the output information. console.debug () ///output information in the console window, plus a blue icon in front of the output information. Console.warn () //output information, in front of a yellow triangle, indicating a warning; console.error () //output information, with a red fork at the top, indicating an error, and displaying the stack of errors occurring console.table () //can convert data of composite type to table display. console.count () //used to count, output how many times it was called. Console.dir () //is used to inspect an object (inspect) and display it in a format that is easy to read and print. console.dirxml () //For displaying DOM nodes in the form of a directory tree. Console.assert () //accepts two parameters, the first argument is an expression, and the second argument is a string. The second parameter is output only if the first argument is false, otherwise there will be no result. //These two methods are used for timing and can calculate the exact time spent on an operation. console.time ()console.timeend ()the//time method means that the timing begins, and the Timeend method indicates the end of the timing. Their arguments are the names of the timers. After calling the Timeend method, the console window displays the timer name: Time spent. console.profile () //used to create a new performance tester (profile) whose parameters are the name of the performance tester. console.profileend () //is used to end the running performance tester. Console.group ()console.groupend ()the two methods above are used to group the displayed information. It is only useful when outputting a large amount of information, divided into a set of information, can be folded/expanded with the mouse. console.groupcollapsed () ///is used to group the displayed information, and the contents of the group are closed on the first display (collapsed) instead of expanded. console.trace () //Displays the calling path of the currently executing code in the stack. console.clear () //is used to clear all output from the current console, and the cursor is reset to the first row.

I wish I can find a good job!!!

Native JS object-related API collections

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.