1. What is the operation effect of the following code? Why?
<meta charset= "Utf-8" >
<title>dom Advanced </title>
<script type= "Text/javascript" >
Window.onload=function () {
var buttons=document.getelementsbyname (' button1 ');
for (Var i=0;i<buttons.length;i++) {
Buttons[i].onclick=function () {
alert (i);
};
}
};
</script>
<body >
<input type= "button" Name= "Button1" value= "button 1"/>
<input type= "button" Name= "Button1" value= "button 2"/>
<input type= "button" Name= "Button1" value= "button 3"/>
<input type= "button" Name= "Button1" value= "button 4"/>
<input type= "button" Name= "Button1" value= "button 5"/>
</body>
2. What is the operation effect of the following code? Why?
function AA ()
{
Alert ("AAA");
return function () {alert ("BBB");};
}
alert (AA);
Alert (AA ());
Alert (AA () ());
3. What is the operation effect of the following code? Why?
function AA ()
{
Alert ("AAA");
return function () {alert ("BBB");};
}
SetInterval (aa,1000);
SetInterval (AA (), 1000);
4. What is the operation effect of the following code? Why?
SetInterval (Alert ("a"), 1000);
SetInterval (function () {alert ("a");},1000);
5. What is the result of the following code operation?
var x=1;
var y=0;
var z=0;
function Add (n) {N=n+1;return n;}
Y=add (x);
function Add (n) {N=n+3;return n;}
Z=add (x);
What are the values for Y and z?
6.
var x=1;
var y=0;
var z=0;
var add = function (n) {N=n+1;return n;}
Y=add (x);
Add =function (n) {N=n+3;return n;}
Z=add (x);
What are the values for Y and z?
JavaScript Six Puzzles