Javascript Developer JSE 40 01 · Free Practice Question Easy
Question 8
Q125 - Control Flow
What keyword does the function declaration start with?
-
A
let -
B
procedure -
C
fun -
D
function
Reveal correct answer
Correct answer: D
Explanation
Topic: function declaration
Try it yourself:
- function test() {
- console.log("Hello");
- }
- test(); // Hello
Explanation:
The function declaration (function statement) defines a function.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function
Q125 (Please refer to this number, if you want to write me about this question.)
A. The keyword "let" is used for declaring variables in JavaScript, not for defining functions. While "let" is important for variable declaration and scoping, it is not the correct keyword for starting a function declaration.
B. The keyword "procedure" is not a valid keyword in JavaScript for declaring functions. JavaScript does not have a built-in "procedure" keyword for defining functions; instead, the standard keyword is "function" for function declarations.
C. The keyword "fun" is not a valid keyword in JavaScript for declaring functions. In JavaScript, functions are declared using the "function" keyword, so using "fun" instead would result in a syntax error.
D. The keyword "function" is used to declare a function in JavaScript. It is the standard keyword for defining a function and is essential for creating reusable blocks of code that can be called and executed later in the program.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
