Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

JavaScript Online Quiz with Answers

The JavaScript is the most popular scripting languages and it developed by Netscape and used to develop the client-side web applications.

What will happen when the following code is executed?

var x = 5;

console.log(x);

if (true) {

    var x = 6;

    console.log(x);

}

console.log(x);

//The Output will be -

5

6

6

What will happen when the following code is executed?

var x = 5;

console.log(x);

if (false) {

    var x = 6;

    console.log(x);

}

console.log(x);

//The Output will be -

5

5

What will happen when the following code is executed?

var x = 5;

function a() {

    var x = 6;

    return x;

}

console.log(x);

console.log(a());

//The Output will be -

5

6

What will happen when the following code is executed?

var x = 5;

function a() {

    x = 6;

    return x;

}

console.log(x);

console.log(a());

//The Output will be -

5

6

What will happen when the following code is executed?

var x = 5;

function a() {

    let x = 6;

    return x;

}

console.log(x);

console.log(a());

//The Output will be -

5

6

What will happen when the following code is executed?

let x = 5;

function a() {

    let x = 6;

    return x;

}

console.log(x);

console.log(a());

//The Output will be -

Uncaught SyntaxError: Identifier 'x' has already been declared

at: 1: 1

What will happen when the following code is executed?

const x = 5;

function a() {

    let x = 6;

    return x;



This post first appeared on Programming, please read the originial post: here

Share the post

JavaScript Online Quiz with Answers

×

Subscribe to Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×