Question Hoisting in Javascript.
Answer: Hoisting is JavaScript's default behavior of moving declarations to the top.
Question: Write the output
x = 5;
console.log(x);
var x;
Answer: 5;
Question: Write the output
var x;
x = 5;
console.log(x);
Answer: 5;
Question: Write the output
"use strict";
console.log(x);
var x;
x = 5;
Answer: undefined;
Question: Write the output
"use strict";
console.log(x);
var x = 5;
Answer: undefined;
Question: Write the output
"use strict";
console.log(x);
x = 5;
Answer: Uncaught ReferenceError: x is not define;
Question. "use strict" in Javascript.
Answer: The purpose of "use strict" is to indicate that the code should be executed in "strict mode".
Syntax : "use strict";
Question: Write the output
"use strict";
x = 5;
console.log(x);
Answer: ReferenceError: x is not defined
Question: Write the output
x = 5;
console.log(x);
Answer: 5
* x will be create as a global varible
Question: Write the output
"use strict";
console.log(x);
x = 5;
Answer: ReferenceError: x is not define;
Question: Write the output
"use strict";
var x = y = 2;
Answer: ReferenceError: y is not defined;
Question. delete in Javascript.
Answer: it will delete object properties.The delete operator will not delete ordinary variables.However, it will delete "global variables," since they are actually properties of the global object.if in strict mode it will throw an error.
Question: Write the output
"use strict";
var x = 2;
delete x;
console.log(x);
Answer: SyntaxError: Delete of an unqualified identifier in strict mode.
Question: Write the output
var x = 2;
delete x;
console.log(x);
Answer: 2
Question: Write the output
x = 2;
delete x;
console.log(x);
Answer: undefined
Question: Write the output
var t = "test";
var test2.t2 = t;
delete test2.t2;
console.log(t);
Answer : "test";
Answer: Hoisting is JavaScript's default behavior of moving declarations to the top.
Question: Write the output
x = 5;
console.log(x);
var x;
Answer: 5;
Question: Write the output
var x;
x = 5;
console.log(x);
Answer: 5;
Question: Write the output
"use strict";
console.log(x);
var x;
x = 5;
Answer: undefined;
Question: Write the output
"use strict";
console.log(x);
var x = 5;
Answer: undefined;
Question: Write the output
"use strict";
console.log(x);
x = 5;
Answer: Uncaught ReferenceError: x is not define;
Question. "use strict" in Javascript.
Answer: The purpose of "use strict" is to indicate that the code should be executed in "strict mode".
Syntax : "use strict";
Question: Write the output
"use strict";
x = 5;
console.log(x);
Answer: ReferenceError: x is not defined
Question: Write the output
x = 5;
console.log(x);
Answer: 5
* x will be create as a global varible
Question: Write the output
"use strict";
console.log(x);
x = 5;
Answer: ReferenceError: x is not define;
Question: Write the output
"use strict";
var x = y = 2;
Answer: ReferenceError: y is not defined;
Question. delete in Javascript.
Answer: it will delete object properties.The delete operator will not delete ordinary variables.However, it will delete "global variables," since they are actually properties of the global object.if in strict mode it will throw an error.
Question: Write the output
"use strict";
var x = 2;
delete x;
console.log(x);
Answer: SyntaxError: Delete of an unqualified identifier in strict mode.
Question: Write the output
var x = 2;
delete x;
console.log(x);
Answer: 2
Question: Write the output
x = 2;
delete x;
console.log(x);
Answer: undefined
Question: Write the output
var t = "test";
var test2.t2 = t;
delete test2.t2;
console.log(t);
Answer : "test";
Nice Ruchika :)
ReplyDeleteSuggestion: It would be better if you give separate list for questions and a separate one for answers.