DEV Community

swetha palani
swetha palani

Posted on

JavaScript basics interview questions** (Day 8–9 focus) you can practice

Variables & Data Types

  1. What are the different data types in JavaScript?
  2. Difference between var, let, and const with examples.
  3. What is the default value of an uninitialized variable?
  4. How do primitive and reference types differ in JS?
  5. How is typeof null evaluated, and why?

Operators

  1. Explain the difference between == and ===.
  2. What is the difference between ++a and a++?
  3. How does the + operator behave with strings vs numbers?
  4. What is the result of NaN === NaN and why?
  5. Explain the ?? (nullish coalescing) operator with an example.

Functions

  1. What are function declarations vs function expressions?
  2. What are arrow functions, and how do they handle this?
  3. Write a function to reverse a number.
  4. Explain default parameters in functions with an example.
  5. Write a function to check if a number is a palindrome.

🔹 Scope & Hoisting

  1. What is scope in JavaScript?
  2. Difference between global scope, function scope, and block scope.
  3. What is hoisting? Give an example with variables and functions.
  4. Why do let and const have a Temporal Dead Zone?
  5. Explain closures and give a practical use case.

🔹 Coding Challenges

  1. Write a factorial function using recursion.
  2. Create a function to find the maximum number in an array.
  3. Write a function that counts vowels in a string.
  4. Implement a program to swap two numbers without a temporary variable.
  5. Build a simple calculator function that takes two numbers and an operator.

Top comments (0)