1. Write out the following output
var Ten ; Sayhi (); function Sayhi () { ten; Console.info (a); return ( ten);
2. Write out the following output
var Ten ; Sayhi (); function Sayhi () { var; Console.info (a); return A;} Console.log (a); ( ten);
3. Assume that there are 4 P tags on the page
function init () { var ps = document.getElementsByTagName ("P"); for (var0; i < ps.length;i++) { = function () { Console.log (i);}} } Init ();
4. Write output
var add = function (m) { var temp = function (n) { return Add (M + n); } = function () { return m.tostring (2) } return temp;} Console.info (Add (3) (4) (5));
1. Answer
20
20
30
40
2. Answer
NaN
10
NaN
NaN
3. Answer: Click on any one of the returns is 4, because I is a global variable. When clicked, the for loop has been executed. The solution is as follows, or use the ES6 syntax let.
(function (n) { = function () { console.info (n); }}) (i);
4. Answer
1100
JS Program topics