JS Program topics

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.