Search [Enter] to search. Click anywhere to close.

October 13th, 2021

27 Entry Level JavaScript Interview Questions

Here’s a selection of 27 different JavaScript interview questions for beginners. The answers have also been provided in each case.

The intention of this article is to cover some of the typical questions you could expect to receive when preparing for an entry level JavaScript developer interview. As such, the questions and answers provided here are aimed specifically at beginners.

We’ve touched on a variety of topics within the JavaScript domain when compiling these interview questions.

And with that, let’s begin!

The entry level JavaScript interview questions

In no particular order with regards to complexity!

1. What is a variable?

A variable is a container for storing data.

2. What is an array?

An array is a list or collection of values.

3. What is an object?

An object is an entity which can have properties and methods.

4. What is a function?

A function is a block of code that is created to perform or execute a specific task.

5. How would you check if a variable is an array?

There are 3 main approaches to doing this:

const myArray = [1, 2, 3]

Array.isArray(myArray) // true
myArray instanceof Array // true
myArray.constructor === Array // true

Any of those examples would be acceptable.

6. How would you check if an object has a specific property?

There are numerous ways to do this, perhaps the most obvious being the use of hasOwnProperty:

const person = { name: "Sam", age: 34 }

person.hasOwnProperty("name") // true
person.hasOwnProperty("location") // false

7. What’s the difference between var, const and let?

A const variable cannot be assigned a new value (so it can’t be modified, or updated at all) once it has been initialized.

A let variable can.

Var variables behave similarly to let variables. However, unlike let and const — only the function body creates a scope for the var variable.

Bonus points for: expanding upon variable scope in this regard.

8. Is JavaScript strongly typed or loosely typed?

It’s loosely typed, meaning you don’t have to specify the “type” of a variable during initialization.

Bonus points for: mentioning TypeScript.

It’s not strictly answering the question, but TypeScript is a strongly-typed subset of JavaScript.

9. Does JavaScript run on the front end or on the back end?


Traditionally, JavaScript was primarily a front end technology. But these days, a lot of JavaScript runs server-side too, through the use of Node.

10. How would you check if an array contains a specific item?

You would use the includes method on the target array, like so:

const colours = ["red", "blue", "green"]

colours.includes("red") // true
colours.includes("black") // false

11. How would you check the length of a string?

You can check the length property on the target string.

12. How would you check the length of an array?

You can check the length property on the target array.

13. What’s the difference between setTimeout and setInterval?

setTimeout executes a specific piece of functionality after a given number of milliseconds have passed. It executes one time.

setInterval executes a specific piece of functionality every x milliseconds. It keeps executing at regular intervals.

14. What function could you use to return a random number in JavaScript?

You can use Math.random to achieve this.

Or to expand on that, assuming the number should be a whole number and the number should be selected from within a pre-determined range, you can use Math.floor to help:

Math.floor(Math.random() * 10) + 1

This would provide a random whole number between 1 and 10.

15. What’s JSON and what role does it serve?

JSON stands for JavaScript Object Notation. It’s used for storing and transmitting data objects, many APIs return data in the JSON format.

JSON is not specific to JavaScript, though it’s based on the JavaScript object (hence the name). It’s simply a standard format used to represent data in some way, and it’s used widely throughout the software domain in general.

16. What’s the difference between a for loop and a while loop?

The for loop runs a specific number of times based on the operands supplied.

A while loop only runs whilst a given condition is true.

17. What’s the difference between == and ===?

When making comparisons in JavaScript, double-equals (or ==) doesn’t consider the type of variables being compared.

Triple-equals (===) does. As such, === is stricter as the variables must have exactly the same type in order to be considered equal.

Bonus points for: mentioning type coercion. Double-equals firstly coerces each variable to the same type before making the comparison.

This is why:

1 == "1"

Is true.


1 === "1"

Is false.

As far as entry level JavaScript interview questions go, JavaScript’s various operators are a typical example. It’s good to brush up on all of the operators as these form a key part of the JavaScript developer’s skillset.

18. What does window.alert do?

It brings up a popup or a dialog containing containing the text specified when invoking the alert function.

19. How would you log a message to the console?

You’d use console.log(), passing in whatever message it is you want to log in each case.

20. When would we use &&?

The logical and operator, or && allows, us to determine if all of the supplied operands in our expression are true.

Bonus points for: if we involve non-boolean types, we can expect some more intricate results.

and operator
Know your operators!

21. When would we use ||?

The logic or operator, or ||, allows us to determine if at least one of the supplied operands in our expression is true.

Bonus points for: if we involve non-boolean types, we can expect some more intricate results. See my article JavaScript ||, Or The “Or” Operator – A Guide for a deep-drive on this topic (it also applies to &&).

22. What is a ternary operator?

It’s a shortcut for the if/else statement. We can use ? to conditionally assign a variable, for instance. If the condition is true – assign the first value. If it’s false, assign the second value.

Like so:

const defaultName = useDefaultName ? "Fred" : ""

This is definitely an entry level JavaScript interview question, however it’s easy to be caught out on terminology alone. Many of us have used ternary operators before; but I’d imagine it’s the case that not everyone knows them by name!

23. How would you check if a variable is numeric or not?

You can use isNaN to check this.

isNaN stands for is not a number.

24. What’s null?

It’s a primitive type, it represents the intentional absence of a value. So null can be used if we specifically don’t want a variable to be set, for instance.

25. What’s undefined?

undefined represents the value of a variable that has not yet been assigned a value. It’s kind of like the “default” value for a variable upon initialization, in this way.

On the topic of null and undefined, the differences may at first not appear to be very obvious. Without prior preparation, I’d suspect this type of question is a good way to catch out JavaScript entry level developers!

26. What is a global variable?

A global variable is a variable that exists within the global scope.

Bonus points for: demonstrating your knowledge on the topic of variable scope within JavaScript in general.

27. What can I use typeof for?

We can use typeof to return the “type” of a variable.

typeof "Fred" // string
typeof 89 // number
typeof { colour: "orange", shape: "circle" } // object

Bonus points for: expanding on and naming each of JavaScript’s types.

How do I get better at answering JavaScript interview questions like these?

The key is to regularly practice JavaScript. And in particular, focus on getting a good grasp of the fundamentals. These are what will be tested first and foremost when seeking employment as a beginner.

These entry level JavaScript interview questions should give you a good foundation upon which to build in this regard.

There are, of course, a vast number of questions you may be expected to answer.

That’s why it’s a good idea to cover all of the fundamentals and continually practice your JavaScript. You’ll want to enhance your skill-set to the point where you don’t need to think about these type of questions; the answers will come naturally as you’re already very familiar!

Are these really JavaScript interview questions for beginners? I didn’t know some of the answers!

Of course, it’s hard to say definitively where the line between beginner and intermediate actually is.

For that reason, some of these questions may be a little bit harder to answer concisely and accurately than others.

With that in mind, it’s always good to be over-prepared as opposed to being under-prepared ahead of an interview!

Once you feel you’ve covered the JavaScript fundamentals, and you feel comfortable fielding questions on these topics; it’s definitely a good idea to jump into more advanced areas of JavaScript.

Some examples of these more advanced or nuanced topics would be:

  • Closures
  • Scoping in general
  • The use of “this”

And so on.

Check back later for more articles on these very topics.

Further resources for learning JavaScript

I really hope you’ve enjoyed reading through these JavaScript entry level interview questions!

If you’re looking for more resources to aid with your learning, feel free to check out my JavaScript Exercises For Beginners series. There are currently 3 parts, each focussing on a specific JavaScript topic. These are a great way to practice JavaScript and bolster your skill-set.

I’ve also written various JavaScript-based articles that are particularly suitable to entry level or beginner JavaScript developers. Those can all be accessed from the JavaScript category of the site.

Lastly, if you’re particularly interested in React (more specifically, preparing for an entry level React interview — I’ve just written an article called 23 Entry Level React Interview Questions.

Thanks for reading!

Have any questions? Ping me over at @justacodingblog
← Back to blog