What will be the output? ( JavaScript )
console.log ( NaN !== NaN );
console.log ( NaN !== NaN );
Anonymous Quiz
35%
True
45%
False
20%
Error
Visit the website neumorphism.io to create awesome Neumorphism. It's super easy 😃.
🙏🙏🙏
Guys, we have a request to you. If you like our channel, please share with your friends or social media. Here is the link of our channel
http://t.me/WebsiteDesignLearningGroup
Guys, we have a request to you. If you like our channel, please share with your friends or social media. Here is the link of our channel
http://t.me/WebsiteDesignLearningGroup
function sayHi() { console.log(name);
console.log(age); var name = 'Lydia';
let age = 21; } sayHi();
console.log(age); var name = 'Lydia';
let age = 21; } sayHi();
Anonymous Quiz
34%
Lydia and undefined
18%
Lydia and ReferenceError
18%
ReferenceError and 21
30%
undefined and ReferenceError
What is output of the above code?
Anonymous Quiz
54%
0 1 2 and 0 1 2
28%
0 1 2 and 3 3 3
18%
3 3 3 and 0 1 2
Web design & 😃 development
function sayHi() { console.log(name);
console.log(age); var name = 'Lydia';
let age = 21; } sayHi();
console.log(age); var name = 'Lydia';
let age = 21; } sayHi();
🅰NSWER:
Within the function, we first declare the name variable with the var keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of undefined, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the name variable, so it still holds the value of undefined.
Variables with the let keyword (and const) are hoisted, but unlike var, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a ReferenceError.
Within the function, we first declare the name variable with the var keyword. This means that the variable gets hoisted (memory space is set up during the creation phase) with the default value of undefined, until we actually get to the line where we define the variable. We haven't defined the variable yet on the line where we try to log the name variable, so it still holds the value of undefined.
Variables with the let keyword (and const) are hoisted, but unlike var, don't get initialized. They are not accessible before the line we declare (initialize) them. This is called the "temporal dead zone". When we try to access the variables before they are declared, JavaScript throws a ReferenceError.
Web design & 😃 development
What is output of the above code?
Please try this one!!
Web design & 😃 development
What is output of the above code?
🅰️NSWER 🔵
Because of the event queue in JavaScript, the setTimeout callback function is called after the loop has been executed. Since the variable i in the first loop was declared using the var keyword, this value was global. During the loop, we incremented the value of i by 1 each time, using the unary operator ++. By the time the setTimeout callback function was invoked, i was equal to 3 in the first example.
In the second loop, the variable i was declared using the let keyword: variables declared with the let (and const) keyword are block-scoped (a block is anything between { }). During each iteration, i will have a new value, and each value is scoped inside the loop.
Because of the event queue in JavaScript, the setTimeout callback function is called after the loop has been executed. Since the variable i in the first loop was declared using the var keyword, this value was global. During the loop, we incremented the value of i by 1 each time, using the unary operator ++. By the time the setTimeout callback function was invoked, i was equal to 3 in the first example.
In the second loop, the variable i was declared using the let keyword: variables declared with the let (and const) keyword are block-scoped (a block is anything between { }). During each iteration, i will have a new value, and each value is scoped inside the loop.
What is the output of the above code?
Anonymous Quiz
49%
20 and 62.83185307179586
30%
20 and NaN
11%
20 and 63
11%
NaN and 63
This media is not supported in your browser
VIEW IN TELEGRAM
Try to make this animation. After 10-12 hours source code will be given. Everyone should try.😊