What does typeof function () {} return?
Functions are objects, but typeof reports callable objects as "function". Arrays, null and plain objects all give "object".
JavaScript Basics · Exercise 1 of 4
Fifteen multiple-choice questions on JavaScript basics: engines and ECMAScript, Node.js, defer and async, identifiers and reserved words, comments, semicolons and ASI, template literals, typeof and strict mode. Pick an option to check your answer instantly.
What does typeof function () {} return?
Functions are objects, but typeof reports callable objects as "function". Arrays, null and plain objects all give "object".
What does console.log("Hi") return?
Printing is a side effect; the function returns undefined. That is why the browser console shows undefined after a console.log line.
Which line prints Total: 15 when a = 5 and b = 10?
Only backtick strings interpolate, and the placeholder syntax is ${expression}. In quotes, ${a + b} is printed literally.
A file containing document.title = "Home"; is run with node app.js. What happens?
document, window and the DOM are provided by browsers. Node.js offers different APIs (fs, http, process). The code is valid syntax, so it fails only when the line runs.
Line 1 of a script is console.log("start"); and line 40 has a missing closing bracket. What is printed when the script runs?
The whole script is parsed before execution starts. Syntax errors (including early errors such as a let declared twice) stop it before any line runs; ReferenceError and TypeError appear only when the faulty line executes.
Timed online tests with instant scores and explanations.