code is as follows:function sum (num1,num2) { return num1+num2;} function Applysum (num1,num2) { return sum.apply (this,arguments);/* parameter The first is the scope in which the function is run, the second argument is the array equivalent to return Sum.apply (this,[num1,num2]); */}function callsum (num1,num2) { return Sum.call (THIS,NUM1,NUM2);/* The first parameter is the scope in which the function is run, followed by a parameter */}console.log (Applysum (10,10));//20console.log (C
array runs a given function, returning the function that returns true of a set of items (commonly used to query all array items that meet the criteria)[1.5.6.3]foreach (): Runs the given function for each item in the array, this method has no return value (equivalent to a for loop)[1.5.6.4]map (): Each item in the array runs the given function, returning an array of the results of each function call (commonly used to create an array that contains an item corresponding to another array of one by
Use parentheses "()" to group, so that sub-expressions (sub-patterns) can be decorated as a whole, the results of sub-expressions matching are recorded and can be accessed separately./(A (b (CD) {2}) +) ef/The references correspond to each other:\1 Correspondence (A (b (CD) {2}) +)\2 Correspondence (b (CD) {2})\3 Correspondence (CD)str = "Pic1.gif gif2.gif pic.gif";Reg =/(. +) ([1-4]) \.\1/;Arr_m = Str.match (reg);//arr_m = ["Gif2.gif", "gif", "2"]Parse: (. +) Match gif([1-4]) matches a number b
array. This method has no return value.
Map (): Each item in the array is a given function that returns an array of the results of each function call.
Some (): Runs the given function for each item in the array, and returns True if the function returns true for either item.
1 var numbers = [1,2,3,4,5,4,3,2,1];2 3 var everyresult = numbers.every (function (item, index, array) {4 return (item > 2);5 });6 7 alert (Everyresult); False8 9 var someresult = num
Javascript| Reference | object | array sup () to turn text in a string into superscript (superscript) font (toLowerCase () turns text in a string to lowercase
toUpperCase () to capitalize text in a string
b.28 Submit Object
It is a property of the Form object, a Submit button (
Property
Name (name= attribute) of the name objectValue Value= PropertyMethodClick Simulate mouse buttonEvent handlersOnclick Clic
Javascript| Reference | object | Array Links array document an array of link objects in the order in which they appear in the document (the property itself is an object)
Location The URL of the currently displayed document. The user cannot change the document.location (because this is where the document is currently displayed). However, you can change window.location (replacing the current document with oth
There are many JavaScript that do not have to instantiate the built-in objects, as they have been instantiated, as described earlier in object,array,string. Then there are two single built-in objects: Global and math. The global object can be said to be a special object because you cannot see his presence, and all global scope-defined properties and functions are properties of the global object.Here's a discussion of the Math object the Math object pr
. The first element to add to the array.Newelement2 is optional. The second element to add to the array.Newelementx is optional. You can add multiple elements.Return value: The new length after the specified value is added to the array.Description: The push () method adds its parameter order to the tail of the arrayobject. It modifies the arrayobject directly, rather than creating a new array. The push () method and the Pop () method use the advanced post-stack functionality provided by the arra
changed .
Here we re-implement the example of a clock number format output by passing the object:Script> varMyTime=Self.setinterval (function() {getTime (); }, +); //alert ("OK"); functionGetTime () {varTimer= NewDate (); varT={h:timer.gethours (), M:timer.getminutes (), S:timer.getseconds () } //The time object T, passed into the function checktime (), changes the value in the object directly in Checktime (). //Without having to receive the return value and
This article mainly introduces the summary of common operation methods for various reference types in JavaScript, which are basically presented using actual code. It is a comprehensive study note. For more information, see
Object Type
Array typeRe-sorting method: compareAscending Order:
function compare(value1, value2){ if (value1
value2){ return 1; } else{ return 0; }}var values = [0,1,5,10,
1: How to create objects: new and object literalsvar finn=new Object (); Finn.name= "Fiona"; Finn.tostring ()"[Object Object]"var finn={};finn.name= "Fiona"; Finn.tostring ()"[Object Object]"2: When using object literal syntax, the property name can also use a stringvar person={name: "Finn", age:30};p erson.name"Finn"var person={"name": "Finn", "Age": $;p erson.name"Finn"3: Object constructors are not actually called when defining objects through object literals, and Firefox2 and earlier version
One recent project encountered a pit, which is an array reference to a JS string:
Javascript
var str = ' ABCDEFG ';A character that refers to the 3rd position of the stringAlert (str[2]);Most browsers output normal value of C; However, some low-level browsers (such as IE7) do not support such references, and the output is undefined.
In order to achieve compatibility, after the honest use of the String.ch
Today, there is a problem, how to change the parameter changes to the outside of the function, such as:
The output is wood, which means that when myname passes in a function, it is equivalent to having a copy of the myname in the function body, the value of which is equal to MyName, and then the operation in the function body is performed on the copy.
However, when the incoming argument is an array, an object, the changes to the parameters in the function body are reflected on th
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.