obj1 = {o1[drt]:333};var obj2 = {o2[0]:333};
The first three lines of code are several different ways of declaring a variable, that is, a normal variable, an object, an array, and the last three rows that call each of these 3 variables and insert the object. Here's the problem:1. Why Obj1 and OBJ2 statements when the direct error?2. obj did not complain, but why loop his properties when the first attribute is directly called "O" instead of the value "left" of the variable O?
If I wan
Creates a new variable of type date D1.The post-run page will pop up:Fri Sep 16:40:50 gmt+0800Create a new variable d2, assign the value of D1 to D2, set the D2 year to 2013,The post-run page will pop up:Thu Sep 16:40:50 gmt+0800Thu Sep 16:40:50 gmt+0800Even if the D2 is declared as a date type, the result is still the same.indicates that this direct assignment of the date type becomes a reference value, D1, D2 two variables to the same date object. It is important to use the "=" symbol to assig
The problem that occurs yesterday when you use a For loop to go to the weight of an array,
First, the previous and all subsequent elements are compared with the double for loop, and if equal is deleted.
However, problems can occur if there are more than three consecutive equal elements in the array.
var arr = [1,1,1,2,2];
For (Var i=0. i
Output:
This is because when an array deletes an element, the length of the array is reduced by 1
We know that using a prototype chain to implement inheritance is a goodway: Look at an example of a prototype chain inheritance.
function A () {
this.abc =;
}
A.PROTOTYPE.GETABC = function () {return
this.abc;
};
Function B () {
}
B.prototype = new A ();//b completes inheritance through an instance of a, forming a prototype chain (the prototype of B is an instance of a)
var b = new B ();
The relationship is as follows: B (instance)->b.prototype = new A ()-> A.prototype->object.prot
When getting document.getElementById (), use innerHTML to get the tag to get the content, note:1. To allow the content to be loaded before it can be used, otherwise get empty, using: Window.onload = ....2. Or put the script behind the contentDOCTYPE HTML>HTMLLang= "en">Head> MetaCharSet= "UTF-8"> title>title> Script>window.onload= function() { varMyID=document.getElementById ("Con"); //alert ("test");document.write ("contents of original HTML:" +myid.innerhtml+ ""); Myid.inne
stored in the variable is also copied into the space allocated for the new variable.At this point in the variable is the address of the object in the heap memory, so, unlike the simple assignment, the copy of this value is actually a pointer, and this pointer points to an object stored in the heap memory. Then after the assignment operation,Two variables all hold the same object address, the two variables point to the same object. Therefore, changing any one of these variables will affect each
];} Worker.prototype.showJob=function() {Console.log ( This. Job);} Worker.prototype.walk=function(){//The way the prototype chain is used overrides the method in the parent classConsole.log ("Go Backwards");} Worker.prototype.language= "中文版";varp1=NewPerson ("blue", "male") P1.showname ();//BlueP1.showsex ();//maleP1.walk ();//go ahead.Console.log (P1.language)//ChineseConsole.log (PERSON.PROTOTYPE.SHOWJOB)//undefined If you use worker.prototype=person.prototype then there is a subclass Showjob
This is a common problem in javascript:var A=3;var b=a;a=5; The result was 5;; The result is 3; and the situation in the following code has changed: var A=1,b=2,c=3;var array=[a,b,c];a=5;; The result of //was 1, and there was no change; var A=1,b=2,c=3;var Array=[a,b,c]; array[0]=5;; The result is that 1,a has not changed in the following code the situation is different: var A=1,b=2,c=3;var array=[a,b,c]; Array2=array; array[0]=5;; The result is 5;var A=1,b=2,c=3;var Array=[a,b,c];var Array2=ar
The constructor can be used with new, representing the creation of an object, or as a normal function call because it is also a function.function person (name) {this.name=name;} Person (n); alert (window.name);//12You can see that this represents a global window object when the constructor is called as a normal function. Obviously it is not a good practice to call a constructor function as a normal function, and there is no reason to do so. In practice, such strange usages should be eliminated i
What is a cross domain?
Suppose a.com/get.html need to get b.com/ Data.html in the data, and here a.com and B.Com is not the same server, this is Cross-domain Cross-domain will involve JavaScript homology strategy, simply to protect the site security, not by the alien (not homologous) Server JS Modify this site content.Refer to a table to see what conditions are causing the cross-cause:
But sometimes we do need to do this, so what are the ways we
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.