JavaScript Basics Quiz

Test your knowledge of JavaScript fundamentals

25:00
25 min quiz
Question 1 of 520% complete
How do you declare a variable in JavaScript?
1 points

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)
  1. How do you declare a variable in JavaScript?

    Answer: var myVar;

    Variables in JavaScript can be declared using var, let, or const keywords.

  2. 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.

  3. Which of the following are JavaScript data types?

    Answer: string, number, boolean, undefined, symbol, bigint

    All of these are primitive data types in JavaScript.

  4. How do you write a comment in JavaScript?

    Answer: // comment

    Single-line comments in JavaScript start with //. Multi-line comments use /* */

  5. 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.