@thebarefootdev
All things Software Dev & Architecture

Follow

All things Software Dev & Architecture

Follow

A small guide to the more important features of JavaScript to [understand] for any technical interview

It's not about the interview, it's about the knowledge!

@thebarefootdev's photo
@thebarefootdev
·May 31, 2021·

9 min read

A while back I posted about the pitfalls of cramming for a coding interview, the problem with these as mere factual recall challenges rather than any strong insight to candidates seeking development positions. I remain steadfast in all I said there, if you are interested have a read.

Certainly, however, there are key points of knowledge any potential employer worth their salt, should seek from any candidates for a particular development role, this is true for any language regardless of what it is. So even if a position is for language A, it is vital the candidates know some more general concepts outside merely that language. For example, the differences between Object-Oriented and Functional approaches to programming, what are the key indicators of each, what is scope, what is a closure, what is the differences between an expression and a statement or the imperative vs declarative style of programming. Do the candidates know this well enough to discuss it and not merely to answer?

In my career, I have gone through all this and more as a candidate, and now at a senior level, and as a contributor to interview planning myself, I can offer a little advice on these things. I have worked in Front end roles and back-end roles significantly and in several languages. However, for this outline, I choose the context of JavaScript, mainly because it's the most common language for development roles these days, and because it proves to be an excellent example of covering (nearly) all areas that should be needed in any coding interview, not merely javascript. It's relatable in many aspects. There is also a ton of vague and poorly constructed information provided both here on hashnode and elsewhere, so I thought I'd like to offer my two cents in contrast to that.

These are not in any specific order though some are certainly more important to know than others, and I will indicate as such.


Object Orientated vs Functional approaches to programming

IMPORTANT!

A vital understanding of the key differences between these two paradigms, Not only semantically but the actual key features that identify as such. A good broad understanding of the ins and outs of OO and FP why they are used in contexts, the good and the bad. Some keywords include;

paradigm, functional purity, side-effects, higher-order functions, expressions, declarations, imperative, declarative, idempotency, arity, prototypical-inheritance, inheritance, inheritance chaining, constructor functions, closures, scope


Prototypical Inheritance in JavaScript

JavaScript is often considered a full OO language. It's true to an extent, but there are caveats, it's not for example the same OO approach as in Java. Despite many similarities, the way inheritance is done in JavaScript does differ. This main difference being the prototype inheritance chain. This allows a flexible inheritance, but for example, doesn't provide for features out of the box such as interfaces. Classes in JavaScript are only sematic wrapping over the constructor function and not Classes in the true sense. Usually, this is not a problem, especially if using libraries and frameworks, but remember there are quirks in plain JavaScript. Even Typescript is a very clever wrapper to the same approach, do not assume its OO in the traditional sense.


JavaScript Event Loop

IMPORTANT!

JavaScript is single-threaded and blocking, you really need to understand what these terms mean, how this affects execution, what is the execution context, how is it managed, what is the stack, and how does this manage the variable scope and assignment in your code? Why is it a loop, where is it started and ended?


Variable Scope and Assignment

IMPORTANT!

Variable scope and how references are handled in Javascript is probably one of the most important areas to understand. The concept of hoisting** must be clear to you to fundamentally grasp what is going on with JavaScript. Know the key differences between let and const, beyond mere assignment management, how does JS treat let and const when parsing and before runtime. Why is var being phased out and why is it not recommended for use anymore. What is scope-leak and why is it bad, what is global scope, what is local scope?


this

IMPORTANT!

The this keyword in JavaScript is one of its more quirky features, it's very important to know what it refers to and how the scope above alters the context of this. How for example does it change in respect to let and const what are some strategies for avoiding complexity in code? How would a functional approach manage the context of this over an OO approach for example, how does it differ in the Browser context than the Node context for example?


Synchronicity and Asynchronicity, Promises and the callback queue

IMPORTANT!

This is related to the section above on the Event Loop, it's an integral part of the lifecycle of a JavaScript application, and is an extended feature of the loop that provides for offsetting tasks as to not block the main thread of execution. Here its vital to understand how the regular synchronicity and blocking nature of JS can be avoided using the callback queue stack, and implemented in code with Promises. What is the purpose of this and how do promises work. It's important to know what Promises are and not how simply how they can be written, remember they are NOT simply a front-end feature for making API requests, they are a fundamental approach to asynchronous programming. For example, it's very advantageous to know, async-await, generator functions and yielding, and the Promise constructor, not merely how to write one in your favorite library like Axios for example. How do promises affect variable assignment, and what are some strategies for writing them, both in the front end and back end.


Node, V8, Libuv

This is probably a little more advanced and involved knowledge but could be expected based on the role being applied for. This is not merely a knowledge of NodeJS and npm for example, this is knowledge for understanding how the event loop and callback queue mentioned above, is actually managed. What is the difference in the scope of Node vs the Browser? How these features provide for a wide range of bindings, to the underlying OS, both sync and async options, as well as extensibility of the library which can be written in C and compiled to JavaScript via Libuv. Basic knowledge of this would be very advantageous , an in-depth knowledge of this is probably for more advanced roles but is still interesting. In this context, it may also be good to know what some alternatives are (no not just Deno 😂) versus what are some of the advantages and disadvantages of this are.


The Browser and the DOM*

IMPORTANT!

The browser context allows for the scope of window to be the global originator how does javascript manage this? What is the DOM (Document Object Model) and why is it important. How is the DOM managed in the context of JavaScript, what are some of the optimal practices for DOM manipulation using Javascript, are there some things that should be avoided, some best practices. What are DOM events, and how are they handled, what is propagation and bubbling, and how can these be managed? A basic understanding on DOM security is good, what are the risks and how could they be managed?


Language evolution, features, and uses

IMPORTANT!

JavaScript has evolved over time and continues to do so. It's important to know how this is managed, what is ECMA, how does the ES number of JavaScript influence the implementation of the language, what have been some of the major changes of the language over the past years, what are some of the new features that were introduced, what purpose do they serve, why should you use them and for what reason? In particular think about some of the following features, what they do, what differences they make, and how they work;

  • Promises
  • Arrow Functions (not just how to write them but what effect they have on scope)
  • Generator Functions
  • Proxies
  • Async Await
  • Fetch (window)

Also, some of the new language features, which allow for a cleaner approach to writing code, what do they do, what do they avoid, and what benefit may they have. e.g;

  • Spread operator
  • Rest operator
  • Class
  • Symbol
  • For in

It is also very important to know some of the key facets of JavaScript, the 8 types (primitive and special types) they key operators including, and some of the key functions on those types. The String Functions, How to work with built-in Dates would be a good advantage, as well as the Math module. Working with Arrays is also vital and it is considered compulsory to understand the main destructive and non-destructive methods e.g; pop, shift, unshift, splice, slice, filter, map, reduce, find, and some of the array iteration approaches, includes, forEach, for, etc. Also be able to know the difference between dependency management in Javascript, the differing approach to modularity, such as the difference between require and import,


Libraries and Frameworks and Approaches

Beyond JavaScript the language exists the ecosystem of libraries and frameworks of which the intention is to provide the language set of javascript without the overhead of masses of raw vanilla code, as well as a more opinionated way of structuring apps and services, and some additional features such as reactive abilities like sockets. Here it's good to know of the most popular, lie React, Angular, Vue, etc, and perhaps a few others.

Usually, in most developer interviews, no one is truly looking for a "React" only developer, (beware employers that are!), even if that is to be the main task. It's crucial to know not only how to use these frameworks, but how they approach the application, what do they actually do under the hood, how does React's approach differs from Angulars for example. Yes, it's good to know the key features and advantages of one, but this is pointless without knowing how it's different from the other. There is no need to provide your input between a library and framework, an employer should not be that pedantic as it's a largely subjective argument.

However, you should be aware of why and how Vue for example, is different from jQuery, or underscore, or how angular approaches dependency injection over something like NextJS, what is ServerSIde rendering versus static sites, What is building and what libraries allow this, why and how, eg. How does Webpack differ from Rollup, or ParcelJS what are some of the advantage and disadvantages.


*To Note

Certainly, this is not exhaustive, and it's crucial to realize you need not only to know, but to understand these, this is the difference between merely recalling and discussing. The sort of "JavaScript" interview that seems to be so popular in many places, is largely redundant in others. Technical interviews are used to discuss and talk around a subject, they may go into detail in some areas but not others, but one doesn't know, so it's good to have a broader knowledge of the subject rather than an overly detailed knowledge of one thing, at the expense of others. It also goes to say that a basic understanding of wider areas such as APIs, HTTP(s) is usually assumed, understanding a little on routing SPA's PWA's is often expected, and it is good to know these in any case.

I'm not suggesting a detailed comprehension of everything javaScript, but it is certainly necessary to show an understanding of how it works, its implementation in modern environments, and its evolution. This is what makes a developer, not merely one who can recall information when asked but also understand and apply it.

Good luck!

 
Share this