Welcome Guest! (App Version 3.1)

websitnero logo name

JS Quiz 1

Q1: Which of the following is the correct java-script syntax?

document.getElementById("p1").innerHTML = "hello world";

document.getElement("p").html("hello world");

document.getElementByTagName("p").text("hello world!");

document.getElementByClass("class1").html = "hello world!";

Q2: How to add an external script in an HTML document?

<script href="someScript.js"></script>

<script url("someScript.js")></script>

<script src="someScript.js"></script>

<link rel="script" href="someScript.js">

Q3: Which of the following is/are the correct syntax for function?

var alpha = function(){}

var function alpha(){}

function alpha(){}

alpha(){}

Q4: How to add a comment in JavaScript?

//this is some comment

<!-- this is some comment -->

/* this is some comment */

# this is some comment

Q5: How will you open new window with java-script?

window.open("http://www.google.com");

window.new("http://www.google.com");

window.url("http://www.google.com")

window.target("http://www.google.com")

Q6: Which of the following will throw error on console.log?

browser.name

client.navName

navigator.deviceMemory

browser.onfileload

Q7: What will be the output of typeof(NaN)?

Not a Number

object

null

number

Q8: What will be the output of the following:

function alpha(a, b){
  console.log(typeof(arguments));
}
alpha(2,3);

object

array

undefined

arguments

Q9: What will be the output of the following:

var a = 10;
var func = function func1(){ 
  var a = 20; 
  return a; 
}
console.log(a);

10

20

undefined

Error

Q10: What will be the output of following?

var a = (function(x){
  delete x;
  return x;
})(1);

 console.log(a);

1

null

undefined

Error

Q11: What will be the output of following?

var y = 1, x = y = typeof x;
console.log(x);

1

null

undefined

NaN

Q12: What will be the output of following?

var a = (function f(f){
    return typeof f();
  })(function(){ return 1; });
  
console.log(a);

function

object

1

number

Q13: What will be output of following?

var foo = {
  bar: function() { return this.baz; },
  baz: 1
};

(function(){
  return typeof arguments[0]();
})(foo.bar);

object

function

number

undefined

Q14: What will be the output of following?

var f = (function f(){ return "1"; }, function g(){ return 2; })();
typeof f;

function

object

string

number

Q15: What will be the output of following?

var x = 1;
x = (x++, x);
console.log(x);

1

2

NaN

undefined

Q16: What will be the output of following?

x = (2, 3);
console.log(x);

2

3

Error

(2, 3)

Q17: What will be output of following?

var x = [typeof x, typeof y][1];
console.log(typeof typeof x);

array

object

number

string

Q18: What will be the output of the following?

(function(){
  var a = b = 3;
})();

console.log(a, b);

3, 3

undefined, 3

3, undefined

Error

Q19: What will be the output of the following?

var myObj = {
  foo: "bar",
  func: function() {
    var self = this;
    console.log(this.foo);
    console.log(self.foo);
    (function() {
      console.log(this.foo);
       console.log(self.foo);
    }());
  }
};
myObj.func();

bar, bar, bar, bar

bar, bar, undefined, undefined

bar, bar, undefined, bar

bar, undefiend, bar, undefined

Q20: What will be the output of following?

function foo1()
{
  return {
      bar: "hello"
  };
}

function foo2()
{
  return
  {
      bar: "hello"
  };
}
console.log(foo1());
console.log(foo2());

Error

Object, Object

hello, hello

Object, undefined

Q21: What will be the output of the following?

console.log(typeof("hello"/4));

string

undefined

Error

number

Q22: What will be the output of the following?

0.3

"0.1 + 0.2"

Error

0.30000000000000004

Q23: What will be the output of following?

(function() {
    console.log(1); 
    setTimeout(function(){console.log(2)}, 1000); 
    setTimeout(function(){console.log(3)}, 0); 
    console.log(4);
})();

1 2 3 4

1 3 4 2

1 4 3 2

1 4 2 3

Q24: 24 What will be the output of the following?

for (var i = 0; i < 5; i++) {
  setTimeout(function() { console.log(i); }, i * 1000 );
}

0 1 2 3 4

1 2 3 4 5

5 5 5 5 5

Error

Q25: Which is the enclosing tag of all the content on a web page?

console.log(false == '0')
console.log(false === '0')

true false

false false

false true

true true

WebsiteNero is highly optimized for learning various website developing technlogies. We try our best to add maximum modules and examples to help learn the concepts clearly and vividly. We try to present all content and examples as simple as we can removing any complexity to hurdle easy understanding. We try best provide you with worthful content, but we cannot guarantee full correctness of all the content on this site. While using this website, you agree to have read and accepted all our terms of use and conditions, cookie, and privacy policy. Copyright, 2013-2018 by websitenero.com. All Rights Reserved.