Javascript quiz questions

Javascript interview questions

  • 1.

    Is it valid to pass an anonymous function as an argument to another function?

    1. True

    2. False

    Answer
  • 2.

    Which of the following statements is valid for the features of JavaScript?

    1. JavaScript is a lightweight, interpreted programming language.

    2. All

    3. JavaScript is designed for creating network-centric applications.

    4. JavaScript is complementary to and integrated with Java.

    Answer
  • 3.

    What is the result of the below JavaScript code when the functions get called in the order as mentioned?

    function first() {
        window.a = 3;
    }
    function second() {
        alert(a);
    }
    1. 0

    2. 3

    3. null

    4. undefined

    Answer
  • 4.

    Which of the following function of String object produces an HTML hypertext link for requesting another URL?

    1. link()

    2. sup()

    3. small()

    4. sub()

    Answer
  • 5.

    Which of the following function of String object would compare a regular expression with a string?

    1. search()

    2. match()

    3. replace()

    4. concat()

    Answer
  • 6.

    Which is the use of typeof operator in JavaScript?

    function() {
        var a = 10;
        if(a > 5) {
            a = 7;
        }
        alert(a);
    }
    1. Its value is a string indicating the data type of the operand.

    2. The typeof is a unary operator. It should occur before the single operand, which can be of any type.

    3. Both of the above.

    4. None

    Answer
  • 7.

    Select a function of Array object which returns a new array comprised of the current array /or its value(s)?

    1. concat()

    2. pop()

    3. push()

    4. some()

    Answer
  • 8.

    Select a String function that creates a string and display in a big font as if it were in a tag?

    1. big()

    2. blink()

    3. italics()

    4. anchor()

    Answer
  • 9.

    Which of the following JavaScript code snippet would create an object?

    function() {
        var a = 10;
        if(a > 5) {
            a = 7;
        }
        alert(a);
    }
    1. var holder = new Object();

    2. var holder = Object();

    3. var holder = new OBJECT();

    4. var holder = new holder();

    Answer
  • 10.

    What is the result of the below JavaScript code when the functions get called in the order as mentioned?

    var a = 5;
    function first() {
        a = 6;
    }
    function second() {
        alert(a);
    }
    1. 0

    2. 5

    3. null

    4. undefined

    5. 6

    Answer
  • 11.

    Which of the following method of Boolean object returns a string depending upon the value of the object?

    1. toSource()

    2. toString()

    3. valueOf()

    4. None

    Answer
  • 12.

    What is the output of the following JavaScript snippet?

    function() {
        var a = 10;
        if(a > 5) {
            a = 7;
        }
        alert(a);
    }
    1. null

    2. 7

    3. undefined

    4. 10

    Answer
  • 13.

    Which of the following is the output of the below JavaScript code?

      var x = [typeof x, typeof y][1];
      typeof typeof x;
    1. "number"

    2. "string"

    3. "undefined"

    4. "object"

    Answer
  • 14.

    Which of the following is the output of the below JavaScript code?

    function() {
        if(true) {
            var a = 5;
        }
        alert(a);
    }
    1. undefined

    2. 5

    3. null

    4. 0

    Answer
  • 15.

    Which of the following will return the type of the arguments passed to a function?

    1. using getType function

    2. using typeof operator

    3. Both of the above.

    4. None

    Answer
  • 16.

    Which of the following function of String object returns the capitalized string while respecting the current locale?

    1. toLocaleUpperCase()

    2. substring()

    3. toUpperCase()

    4. toString()

    Answer
  • 17.

    What is the function of Array object that adds and/or removes elements from an array?

    1. toSource()

    2. sort()

    3. unshift()

    4. splice()

    Answer
  • 18.

    When executed, the below JavaScript code will pop up three alerts. Identify the corret answer?

    var a = 6;
    function test() {
        var a = 7;
        function again() {
            var a = 8;
            alert(a);  // A
        }
        again();
        alert(a);  // B
    }
    test();
    ​alert(a);​  // C
    1. 8; 6; 7

    2. 7; 6; 8

    3. 6; 7; 8

    4. 8; 7; 6

    Answer
  • 19.

    Which of the following methods removes the last element from an array and returns that element?

    1. pop()

    2. get()

    3. last()

    4. None

    Answer
  • 20.

    What is the function of Array object that runs through each element of the array?

    1. concat()

    2. forEach()

    3. every()

    4. filter()

    Answer

© 2017 QuizBucket.org