10 Javascript Interview Questions Every Junior Developer Should Know

Aktaruzzamanjoti
3 min readMay 8, 2021
javascript interview questions

Problem Solving Related

Problem-solving is common in interview boards. If you want to a developer, you have to know minimum knowledge of problem-solving. In an interview, there is some common problem-solving questions that I talk about now.

Let’s see which type of questions to be asked on the interview board.

  1. Find the largest element of an array.
  2. Remove duplicate items from an array.
  3. Count the number of a word from a string.
  4. Reverse a string.

Another Problem Solving Questions You need to know

If the job you are applying for requires you to think solve problems, you may be asked some analytical interview questions. These problem-solving questions will vary across industries but you have to know these knowledge to do very well in interview board.

  1. Calculate Factorial of a number using for loop.
  2. Calculate Factorial in a Recursive Function.
  3. Create a Fibonacci Series using for loop.
  4. Create Fibonacci Series in a recursive way.
  5. Check whether a number is a prime number or not.

Truthy and Falsy values

In JavaScript, truthy are expressions which evaluates to boolean true value and falsy evaluates to boolean false value.

false , 0 , -0 , 0n , “” , null , undefined , and NaN are considered as a falsy values. Without this values , all are called Truthty values.

Null vs Undefined

Null means an empty or non-existent value which is assigned, and explicitly means nothing. On the other hand, Undefined typically means a variable has been declared but not defined yet.

Double equal vs Tripple equal

Double equal will do a comparison with value. Where Tripple equal will do same thing but it compares with type and value both. If type differs, false is returned.

Global Scope, Block Scope

In a browser, the global scope is controlled by the window object. In Node. js, it’s controlled by the global object. Block scopes are what you get when you use if statements, for statements.

Closure

const add = (function () {
const counter = 0;
return function () {counter += 1; return counter}
})();

add();
add();
add();

// the counter is now 3

The variable add is assigned to the return value of a self-invoking function.

The function sets the counter to zero (0), and returns a function expression.

This way add becomes a function. And it can access the counter in the parent scope.

This is called a JavaScript closure.

Bind, Call and Apply

Call( ): The call() method creates a function with a given ‘this’ value and arguments provided one by one.

Apply( ): Invokes the function and allows to pass in arguments as an array.

Bind(): It returns a new function that allows you to pass in an array and any number of arguments.

How to use DOM and EVENTS

Using DOM, JavaScript can perform multiple tasks. It can create new elements and attributes. DOM changes the existing elements and attributes and remove existing elements and attributes.

Here are some attributes which is used in DOM.

  1. getElementById, innerHTML Example
  2. getElementById: To access elements and attributes whose id is set.
  3. innerHTML: To access the content of an element.
  4. getElementByTagName: To access the element’s tag.
<h3 id="dom">Welcome</h3><p>This is the welcome message.</p><h3>Technology</h3><p>This is the welcome message.</p><p id="second">This is the technology section.</p><script type="text/javascript">const text = document.getElementById("dom").innerHTML;const paragraphs = document.getElementsByTagName("p");document.getElementById("second").innerHTML = "The message is changed."</script>

Thanks for with me. I discussed about only some interview questions. It’s not in the end. There are some more important inview questions. I’ll talk about later another day. All the best wishes for you!

--

--

Aktaruzzamanjoti

I'm a curious Web developer who is hungry to know about development