Which keyword starts a named function declaration in JavaScript?

Prepare for the uCertify CIW Advanced HTML5 and CSS3 Specialist Exam. Dive into essential topics with flashcards and multiple-choice questions. Enhance your understanding with hints and explanations for each question. Pass your exam confidently!

Multiple Choice

Which keyword starts a named function declaration in JavaScript?

In JavaScript, a named function declaration starts with the function keyword, which signals that you are declaring a function and giving it a name. For example, function greet(name) { return 'Hello ' + name; } shows function as the starting token, then the function name greet, then parameters and the body. This form creates a function that is hoisted, meaning it’s available before its line of code runs. The other keywords—var, let, and const—are used to declare variables, not functions, so they don’t start a function declaration. A function expression can also begin with function, but it’s part of an expression and typically assigned to a variable, e.g., const greet = function(name) { ... }. A named function declaration, however, uses the function keyword directly followed by the function name.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy