Http://www.cnblogs.com/meil/archive/2006/06/28/437527.html This article lists various JavaScript objects and arrays, including a short description of the work done by each of these objects or arrays. As well as its associated property methods, as well as the event handlers, which also indicate that the parent object of the object or array may also need to refer to the Super-text object Hierarchy page in online companion (HTTP/ www.netscapepress.com/su
Today encountered a pit, specifically not much to say, directly on the code var a = [[],[],[1,2,3]]var b = [' Color ', ' size ', ' size ']var arr = []fo R(Let i = 0; i ) {= { }for (Let j = 0; J ) {= a[i][j] arr.push (obj) console.log (arr) console.log (obj) }} Console.log (arr)I expect the result of ARR should be[{' Size ': 1}, {' Size ': 2}, {' Size ': 3}]Finally arr's the result is this[{' Size ': 3}, {' Size ': 3}, {' Size ': 3}]Ask in a group of friends a
a copy of Num. Copy of similar operating systemvar num=10;var num2=num;num2=100; //Does not affect the value of NumConsole.log ("num=%d num2=%d", num,num2);Results2. Reference type, copy reference addressvar person1=new Object ();person1.age=18;var Person2=person1; //Copy the reference address, person2 the variable, and point to an objectperson2.age=30; //is act
not related;The reference type also copies the new variable, but the variable is a pointer to the new and old two pointers to the same object3. Parameter passing of the function: all parameter passing principle is the argument that the external variable is passed to the function by means of copying. Therefore, the operation of parameters inside the function has no effect on the external original variableThe following are examples of parameters as bas
How do I refer to a variable in PHP in JavaScript?
For example: In PHP already has a variable $filename value of "1.txt", the user click the Delete button to pop up the JavaScript confirmation dialog box, the content is "delete 1.txt". How do I reference the value of $filename?
(Beginner, problem may be some idiot, please answer patiently, thank you)
Reply co
); Returns 2parseint ("10", 8); Returns 8parseint ("10", 10); Returns 10If the decimal number contains a leading 0, it is best to use cardinality 10 so that the octal value is not unexpectedly obtained. For example:parseint ("010"); Returns 8parseint ("010", 8); Returns 8parseint ("010", 10); Returns 10The Parsefloat () method is similar to the parseint () method, viewing each character starting at position 0 until the first non-valid character is found, and then converting the string before the
parameter will be changed (accept the values of all parameters)The value we want to update must be placed on the last side, because the more the parameter, the higher the permissions. To overwrite the contents of the former duplicates.Let SourceItem = { 0, ' Learn Redux ', false}object.assign ({}, SourceItem, { true})2. Object operation: Add a new itemIn fact, as in the above, write a new key value pair even if newLet SourceItem = { 0, ' Learn Redux ', false} Object.assign
(function (Item,index,arr) {});//iterates over each item of the array, processes each item, returns the processing result of each item, and forms a new array to returnColor.foreach (function (Item,index,arr) {});//iterate over each item of an array13, the reduction methodReduce (function (prev/* */,cur/* The current item */,index/* the current item's position */,arr/* the array itself */) {//From left to right, iterating through all the items of the array, constructing a final value, returning
Let's take a look at an example:
The above example seems simple, but the result is not well understood, it is easy to think of people around-"a.x not point to object a?" Why is log (a.x) undefined? "," b.x should not be the same as a.x? Why does log come out with 2 objects?
Of course, you can first of all understand, if you can see the reason and the mechanism of work naturally there is no need to continue to look down.
The following is an analysis of the work steps of this sim
This afternoon, thinking about calling the function, what about the arguments passed to the executing function. When the type of the value is different, there is no change.When the value of the parameter is the basic type, this time is passed by value, this is definitely clear, but the time is the reference type, this time what is the situation ah. When we pass an object as an argument, we find out how to run the Funx function, but the global objec
then accesses o when name is modified to B. The reference to O here points to the new object B;Look at the following example and everyone will understand.function Quotefn (obj) { varnew Object (); = o; = "Tony"; =; = "Men";} var person = { "miracle", }console.log (person.name); console.log (person.age); Console.log (person.sex);In this example, you first create the person object and set its name attribute value to "miracle",
variable, the old and new variables are not related;
The reference type also duplicates the new variable, but the variable is a pointer to the same object as the old two pointers
3. Parameter Pass of function: all the parameter transfer principle is to pass the external variable to the function's parameter by the way of copying. Therefore, the operation of the parameter inside the function has no effect on the external original variable
The follow
The original type exists in the heap, the reference type exists in the stack, and the reference type is a pointer to the memory of the object.There are 5 primitive types :Undefined, Null, String, Boolean,number.JavaScript provides a typeof method to determine the value type, and the result of the original type is undefined,object, String, Boolean, number (typeof null The result is object, which is a histori
= [3,5,9,6,15,28,7] var max = Math.max.apply (math,a Rray);The Ceil () method performs an upward rounding such as math.ceil (5.1) execution results equal to 6 for the value between X and x+1 that returns the X+1 value of this methodThe floor () method rounds down the Ceil () method for example Math.floor (5.1) Execution result = 5 Returns the value of x after the value between x and X+1 is executedRound () method standard Math roundingThe random () method produces a 0-1-free number without the
Reference
Aaron's JavaScript definition object writing (Arrangement)
Several simple methods for defining objects in Javascript
1. constructor method. All attributes and object methods are defined in constructor.
Advantage: Dynamic Transmission Parameters
Disadvantage: each time an object is created, the same method and function object will be created, occup
to lowercase.
ToString ()Returns the original string value.
toUpperCase ()Returns a copy of the specified string in which all characters have been converted to uppercase.
Trim ()Returns a copy of the specified string, with both front and back whitespace characters removed.
ValueOf ()Returns the original string value.
Static methodsString.fromCharCode ()Creates a new string using the character encoding passed in as a parameter.
HTML methodSince these are not s
The example in this article describes the use of JavaScript reference assignment (address-passing value). Share to everyone for your reference. Specifically as follows:
JavaScript by default, arrays, objects, and functions are reference assignments, as shown in the followin
Object-Oriented ProgrammingJavascript uses "Object-Oriented Programming" or "Object-Oriented Programming. The so-called "Object-Oriented Programming" refers to dividing the scope of JavaScript into large and small objects. objects are still divided into objects until they are very detailed. All programming is based on objects, object-based. A variable or webpage document, window, or screen is an object. This chapter describes how
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.