Javascript quiz questions

Javascript interview questions

  • 1.

    How to write an IF statement for executing some code if "i" is NOT equal to 5?

    1. if i <> 5

    2. if (i != 5)

    3. if (i <> 5)

    4. if i =! 5 then

    Answer
  • 2.

    How to write an IF statement in JavaScript?

    1. if (i == 5)

    2. if i = 5 then

    3. if i = 5

    4. if i == 5 then

    Answer
  • 3.

    How do you call a function named "myFunction"?

    1. call myFunction()

    2. call function myFunction()

    3. myFunction()

    Answer
  • 4.

    How do you create a function in JavaScript?

    1. function myFunction()

    2. function:myFunction()

    3. function = myFunction()

    Answer
  • 5.

    How do you write "Hello World" in an alert box?

    1. msg("Hello World");

    2. alertBox("Hello World");

    3. msgBox("Hello World");

    4. alert("Hello World");

    Answer
  • 6.

    The external JavaScript file must contain the <script> tag.

    1. True

    2. False

    Answer
  • 7.

    What is the correct syntax for referring to an external script called "xxx.js"?

    1. <script name="xxx.js">

    2. <script src="xxx.js">

    3. <script href="xxx.js">

    Answer
  • 8.

    Where is the correct place to insert a JavaScript?

    1. The <head> section

    2. Both the <head> section and the <body> section are correct

    3. The <body> section

    Answer
  • 9.

    What is the correct JavaScript syntax to change the content of the HTML element below?

    <p id="demo">This is a demonstration.</p>

    1. #demo.innerHTML = "Hello World!";

    2. document.getElement("p").innerHTML = "Hello World!";

    3. document.getElementById("demo").innerHTML = "Hello World!";

    4. document.getElementByName("p").innerHTML = "Hello World!";

    Answer
  • 10.

    Inside which HTML element do we put the JavaScript?

    1. <scripting>

    2. <script>

    3. <javascript>

    4. <js>

    Answer
  • 11.
    "1" - - "1";

    What is the result?

    1. 0

    2. 2

    3. 11

    4. "11"

    Answer
  • 12.

    What is alerted?

    function bar() {
        return foo;
        foo = 10;
        function foo() {}
        var foo = '11';
    }
    alert(typeof bar());

     

    1. number

    2. function

    3. undefined

    4. string

    5. error

    Answer
  • 13.

    What is the result?

    (true + false) > 2 + true;
    1. true

    2. false

    3. NaN

    4. TypeError

    Answer
  • 14.

    What is the result?

    (true + false) > 2 + true;
    1. true

    2. false

    3. NaN

    4. TypeError

    Answer
  • 15.

    What is the result?

    Number("1") - 1 == 0;

     

    1. True

    2. False

    3. TypeError

    Answer
  • 16.

    What will be alerted?

    function aaa() {
        return
        {
            test: 1
        };
    }
    alert(typeof aaa());

     

    1. function

    2. number

    3. object

    4. undefined

    Answer
  • 17.

    What is printed in the console?

    var foo = function foo() {
        console.log(foo === foo);  
    };
    foo();

     

    1. true

    2. false

    3. Reference error

    Answer

© 2017 QuizBucket.org