JavaScript Basics
JavaScript Basics - Important Points
1. | Which of the following is not a valid way to declare a variable in JavaScript? |
---|
A. var myVar = 5;
B. let myVar = 10;
C. const myVar = "hello";
D. myVar = true;
View Answer Discuss Work SpaceAnswer: option d
Explanation:
D is not a valid way to declare a variable in JavaScript. You must use a declaration keyword such as var, let, or const.
2. | What does the typeof operator return for null in JavaScript? |
---|
A. null
B. undefined
C. object
D. number
View Answer Discuss Work SpaceAnswer: option c
Explanation:
3. | What is the difference between let and var in JavaScript? |
---|
A. There is no difference between let and var.
B. let is block-scoped, while var is function-scoped.
C. var is block-scoped, while let is function-scoped.
D. let can only be used to declare global variables.
View Answer Discuss Work SpaceAnswer: option b
Explanation:
4. | Which of the following is not a way to loop through an array in JavaScript? |
---|
A. for loop
B. while loop
C. do-while loop
D. if statement
View Answer Discuss Work SpaceAnswer: option d
Explanation:
5. | What does NaN stand for in JavaScript? |
---|
A. Not a Name
B. Not a Number
C. Not a Null
D. Not a Boolean
View Answer Discuss Work SpaceAnswer: option b
Explanation: