JavaScript Fundamentals

Master the basics of JavaScript with questions on variables, functions, arrays, and DOM manipulation.

10 Questions beginner

Quiz Questions

  1. Which keyword is used to declare a constant in JavaScript?
    • var
    • let
    • const
    • constant
  2. What is the result of typeof null in JavaScript?
    • 'null'
    • 'undefined'
    • 'object'
    • 'boolean'
  3. How do you write 'Hello World' in an alert box?
    • alertBox('Hello World')
    • alert('Hello World')
    • msg('Hello World')
    • popup('Hello World')
  4. Which method adds an element to the end of an array?
    • push()
    • pop()
    • shift()
    • unshift()
  5. What does === operator check?
    • Value only
    • Type only
    • Both value and type
    • Neither
  6. How do you create a function in JavaScript?
    • function myFunction()
    • create myFunction()
    • def myFunction()
    • func myFunction()
  7. What is the correct way to write a JavaScript array?
    • var colors = 'red', 'green', 'blue'
    • var colors = (1:'red', 2:'green', 3:'blue')
    • var colors = ['red', 'green', 'blue']
    • var colors = 1 = ('red'), 2 = ('green'), 3 = ('blue')
  8. Which event occurs when the user clicks on an HTML element?
    • onmouseclick
    • onclick
    • onchange
    • onmouseover
  9. What is NaN in JavaScript?
    • A string
    • A number
    • Not a Number
    • Null and None
  10. How do you find the length of an array named 'arr'?
    • arr.length
    • arr.size()
    • arr.len
    • length(arr)
Take this Quiz