JavaScript Basics Quiz
Test your knowledge of JavaScript fundamentals
About this JavaScript quiz
This beginner-level quiz has 5 questions covering basics, variables, functions. You have 25 minutes, and you need 70% to pass. Every question comes with an explanation, so a wrong answer still teaches you something. Questions mix multiple choice, multiple answer and true/false formats.
Revise before you start
Answers and explanations
Show all 5 answers (spoilers)
How do you declare a variable in JavaScript?
Answer: var myVar;
Variables in JavaScript can be declared using var, let, or const keywords.
What will console.log(typeof null) output?
Answer: object
This is a well-known quirk in JavaScript. typeof null returns "object" due to a bug in the original implementation.
Which of the following are JavaScript data types?
Answer: string, number, boolean, undefined, symbol, bigint
All of these are primitive data types in JavaScript.
How do you write a comment in JavaScript?
Answer: // comment
Single-line comments in JavaScript start with //. Multi-line comments use /* */
Complete the function declaration: _______ myFunction() { return "Hello"; }
Answer: function
The function keyword is used to declare functions in JavaScript.
Want more practice? Browse all web development quizzes or try the code yourself in the live playground.