JavaScript Interview Preparation

Adrian Trujillo Duron
4 min readJan 25, 2022

--

Photo by Pankaj Patel on Unsplash

If you’re applying for a Software Engineer position, chances are you’ll encounter some technical interview or coding challenge. For junior engineers like me applying for software programming roles, the technical part of the interview can be the most terrifying part. Recently I’ve been preparing for JavaScript interviews and I would like to share with you some of my research!

What is JavaScript?

JavaScript is a scripting or programming language that allows you to implement complex features on web pages — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated graphics, scrolling video jukeboxes, etc.. — you can bet that JavaScript is probably involved. It is the third layer in the cake of standard web technologies, the others being HTML and CSS.

What is the difference between “==” and “===”?

The difference between these two operators may seen simple, but it’s very important to know. Both serve as comparison operators between two variable or values, the divergence lies on the datatype they compare. The “==” operator will compare both variables irrespective of datatype, while the “===” operator will first check the datatype and then compare the values.

Here’s a quick example using the operators:

The first if statement will return true, since the operator will only check for same values, meaning that numbers can be in string format. The second comparison will return false, this because the datatype comparison will cause the comparison to fail.

What are High-Order Functions?

A high-order function is a function that operates on functions, taking one or more functions as arguments and returning a new function.

This not() function is a higher-order function because it takes a function argument and returns a new function.

What is Hoisting?

Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables or classes to the top of their scope, prior to execution of the code. It allows functions to be safely used in code before they are declared. Variable and class declarations are also hoisted, so they too can be referenced before they are declared. How ever when trying to reference the a variable or class an undefined and ReferenceErrorvalues will be outputted since the they are not initialized yet. I would recommend only using hoisting with functions to avoid these kind of errors.

What is a Closure?

A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). With this you can do two things:

  • It gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time. So you will be able to access every outer function layer, including global scope, from within the inner function, this just works one way.
  • Have access to the lexical environment within which the function was declared. This environment consists of any local variables that were in-scope at the time the closure was created. So even if you declared the function in a local scoped with some variables locally defined, you will still have access to them if running the function in a global scope.

What is Currying?

Photo by amirali mirhashemian on Unsplash

Yes, I too thought that curry was the delicious asian dish! But turns out this is a concept in JavaScript. Currying refers to a function that takes one argument at a time and returns a new function expecting the next argument. It is a transformation of functions that translates a function from callable as f(a, b, c) into callable as f(a)(b)(c). So, let’s check out currying in action!

As you can see currying does not change functionality, it just changes the way the function is invoked!

What are Arrow Functions?

Photo by Vince Fleming on Unsplash

An arrow function expression is a compact alternative to a traditional function expression, but is limited and can’t be used in all situations. It is mainly used to simplify and reduce the number of lines it takes to declare a function. Some of the limitations lie on that arrow functions does not have its own binding to this, instead they use the context of their parent. They are also not suitable for using the call(), apply() and bind() methods, since they generally rely on establishing scope for functioning.

What is a Prototype?

Almost every JavaScript object has a second JavaScript object associated with it. This second object is known as a prototype, and the first object inherits properties from the prototype. Prototypes are the mechanism by which JavaScript objects inherit features from one another. Every object in JavaScript has a built-in property, which is called its prototype. The prototype is itself an object, so the prototype will have its own prototype, making what’s called a prototype chain. The chain ends when we reach a prototype that has null for its own prototype.

What did you think about these questions? Please let me know in the comments below if they were helpful or if you feel that an important concept is missing in the post! See you soon coding in your new JavaScript developer role!

--

--