JavaScript Basics
JavaScript Basics - Important Points
11. | What is a callback function in JavaScript? |
---|
A. A function that is called when an error occurs.
B. A function that is called when a button is clicked.
C. A function that is passed as an argument to another function and is called when the first function has finished executing.
D. A function that is used to generate random numbers.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
12. | What is the difference between null and undefined in JavaScript? |
---|
A. There is no difference between null and undefined.
B. null is a value that represents an empty object reference, while undefined is a value that represents an uninitialized variable.
C. undefined is a value that represents an empty object reference, while null is a value that represents an uninitialized variable.
D. null and undefined both represent an uninitialized variable.
View Answer Discuss Work SpaceAnswer: option b
Explanation:
13. | What is the difference between let and const in JavaScript? |
---|
A. There is no difference between let and const.
B. let is block-scoped, while const is function-scoped.
C. const is block-scoped, while let is function-scoped.
D. const can only be used to declare global variables.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
14. | What is the purpose of the return statement in a JavaScript function? |
---|
A. To define the arguments for the function.
B. To declare a variable.
C. To exit the function and return a value.
D. To create a loop.
View Answer Discuss Work SpaceAnswer: option c
Explanation:
15. | What is the difference between a function declaration and a function expression in JavaScript? |
---|
A. There is no difference between a function declaration and a function expression.
B. A function declaration is hoisted to the top of the scope, while a function expression is not hoisted.
C. A function expression is hoisted to the top of the scope, while a function declaration is not hoisted.
D. A function declaration can only be used inside of an object, while a function expression can be used anywhere.
View Answer Discuss Work SpaceAnswer: option b
Explanation: