DEV Community

Cover image for JavaScript Interview Questions and Answers you should know - Junior and Senior
Let's Code
Let's Code

Posted on • Updated on

JavaScript Interview Questions and Answers you should know - Junior and Senior

It is important to be prepared prior to a job interview as you only have 1️⃣ chance to impress and convince the interviewers that you are the one they are looking for. Typically, you will meet up with different engineers who will ask very hard questions, and unfortunately, you will most likely not get the job 🤦🙅 if one of them says 'NO' 🚫 especially the senior ranking interviewer.

There would be a time for an engineer to look for a new role whether it is driven by a new challenge, more money, or to move to a different place.

In this case, it is vital to be completely ready and know the common questions that are commonly asked so you are able to answer correctly and confidently. I have compiled the top 1️⃣0️⃣ Q&A for both Junior and Senior that is guaranteed to be asked on a job interview. I am in the process of writing/compiling HTML and CSS Q&A which I will post here when I get done.

Is there any questions you think we should use instead of what I currently have? What is it and why? No wrong and right answer, I am just curious.

Feel free to bookmark 🔖 even if you don't need this for now. You may need to refresh/review down the road when it is time for you to look for a new role.

Mid - Senior Level Questions and Answers

1. What is a closure?

  • Closure is a function in a function. The inner function has access to the outer's function scope and parameters even after the outer function has returned.

2. What are the differences between call, apply, and bind?

  • call and apply immediately calls a function while bind creates a new function that can be invoked in the future. Arguments with call are passed in one by one, separated with a comma while apply expects an array as its argument.

3. What is an event loop?

  • An event loop is responsible for executing javascript code, collecting and processing events, and executing queued sub-tasks.

4. What is currying function?

  • A currying function is the process of taking a function with multiple arguments and turning it into a sequence of functions each with a single argument.

  • Curried functions are a great way to improve code reusability and functional composition

5. What is prototype in javascript?

  • Prototypes are the mechanism by which JavaScript objects inherit from another object.

6. What is memoization?

  • Memoization is an optimization technique by storing the result of expensive function calls and returning the cached results when the same inputs occur again.

7. What is a higher-order function?

  • a higher-order function is a function that accepts another function as an argument or returns a function as a return value or both of them.

  • Map, filter and reduce are some examples of higher-order functions that are already built-in to JavaScript.

8. What is event delegation?

  • Event delegation is a pattern of adding a single event listener to a parent element instead of multiple elements.

9. Name some ways to handle asynchronous operation in javascript

  • Callback is a function that is used to notify the calling instance

  • Promise is an object representing the eventual completion or failure of an asynchronous operation. A pending promise can either be fulfilled with a value or rejected with a reason.
    Callbacks are attached to the returned promises that make handling of asynchronous code easier and more readable.

  • async/await is a new addition to ES2017 which is syntactic sugar on top of promises and make asynchronous code look synchronous code

10. What is recursion?

  • Recursion is a technique for iterating over an operation by having a function call itself repeatedly until it arrives at a result.

  • This is most effective for solving problems like sorting or traversing the nodes of complex or non-linear data structures

Don't feel like reading? Here is a video -

Entry - Junior Level Questions and Answers

1. What is Javascript?

  • it is the scripting language of the web that was initially intended to run on the browser. Today, JavaScript is used in the server.

2. What is ECMAScript?

  • is a standard specification for scripting languages. JavaScript is based on ECMAScript.

3. What is the difference between == and ===?

== compares values
=== compares both type and value

4. What is a promise?

  • is an object that may produce a single value sometime in the future with either a resolved value or a reason for not being resolved

5. What is strict mode in JS?

  • it is useful for writing secure JS code. It prevents some bugs from happening and throws more exceptions.

6. What is the difference between null and undefined?

null type is an object that is explicitly assigned to a variable.

undefined type is undefined where the variable has been declared but has no assigned value

7. What is AJAX?

  • stands for Asynchronous JavaScript and XML. We can send data to the server and get data without refreshing the page.

8. Explain the difference between synchronous and asynchronous.

  • Synchronous is blocking operation while asynchronous is not. Synchronous complete the current code before the next code is executed while asynchronous continue on the next code without completing the current code

9. What are the differences between var, let, and const

  • var is scoped to a function. let and const are block-scoped. Accessible to nearest curly braces (function, if-else, for-loop)

10. What is the DOM?

  • it stands for Document Object Model. This can be used to access and change the document structure, style, and content.

Don't feel like reading? Here is a video -

If you want to support me - Buy Me A Coffee

Top comments (4)

naorzr profile image

A closure is not a function in a function.
A closure describes a function with it's context (the lexical env variables in which it was defined)

I kinda dislike the notion of "10 things every programmer has to know", it's always subjective to the author work experience and what he finds valuable.

After interviewing hundreds of candidates, classifying seniors from none seniors always boils down to how well and deeply they know the areas that they worked on, and their ability to work independantly and lead something.

frontendengineer profile image
Let's Code • Edited

I like your definition better on closure. 😃

I find '10 things...' very valuable as it summarizes the most important things in one go. Imagine the countless time one spent on a topic gets summarized for someone who may have little or does not have any knowledge on the topic. That is a great braindump and is priceless!

I agreed that the skill and ability to perform the job the only thing that matters in the end. I interviewed and got interviewed numerous times as well. Interviewers typically go through multiple processes from recruiters, 1-hour technical, 4-hour panel, and cultural/behavior interview. Interviewees would not be able to progress interviews if are not able to answer common tech interview questions.

frontendengineer profile image
Let's Code

CSS and HTML Interview Question post - as a supplement to this post to complete the front-end package

frontendengineer profile image
Let's Code • Edited

Are there any questions you think we should use and swap what I currently have? What is it and why? No wrong and right answer, I am just curious.