0% found this document useful (0 votes)
3 views2 pages

Js Tricky Questions

The document presents a series of tricky JavaScript questions focusing on concepts like variable declaration (var, let, const), hoisting, and data types. Each question tests the reader's understanding of JavaScript behavior, such as scope, output of console logs, and type coercion. The questions cover various scenarios including function scope, block scope, and the behavior of null and empty values.

Uploaded by

Ayush kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Js Tricky Questions

The document presents a series of tricky JavaScript questions focusing on concepts like variable declaration (var, let, const), hoisting, and data types. Each question tests the reader's understanding of JavaScript behavior, such as scope, output of console logs, and type coercion. The questions cover various scenarios including function scope, block scope, and the behavior of null and empty values.

Uploaded by

Ayush kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript Tricky Questions: var, let, const,

Hoisting & Types

1. What is the output?


var a = 10;
function test(){ [Link](a); var a = 20; }
test();

2. What happens?
[Link](x);
let x = 5;

3. Output?
for(var i=0;i<3;i++){ setTimeout(()=>[Link](i),0); }

4. Output?
for(let i=0;i<3;i++){ setTimeout(()=>[Link](i),0); }

5. Error or not?
const obj = {a:1}; obj.a = 2;

6. Error or not?
const x = 10; x = 20;

7. Output?
[Link](typeof null);

8. Output?
[Link](1 + '2' + 3);

9. Output?
[Link]('5' - 2);

10. Output?
[Link](a); let a = 10;

11. Output?
var x = 1; { var x = 2; } [Link](x);

12. Output?
let y = 1; { let y = 2; } [Link](y);

13. Output?
[Link](Boolean(''));

14. Output?
[Link]([] + []);
15. Output?
[Link]({} + []);

You might also like