in Full Stack JavaScript


I recently interviewed at a fin-tech startup for a Software Engineer role (mainly front end React). I really liked the CTO and could see their product being a success. I was feeling good. Then came the technical questions. I fumbled the answers to Object Oriented Programming, Functional Programming, and Core JavaScript questions. Dazed, the pair programming exercise didn’t go much better. Even small things like accidentally hitting escape on the new Mac’s ultra sensitive keyboard became a problem. In the midst of all this, I scruffily wrote down the questions asked.

Suffice to say, I didn’t get the job

What I did get though was pertinent feedback – the areas I need to brush up on (listed above) and also ways of doing this e.g. through Founders & Coders. I checked out Founders & Coders Github repo and entry requirements; something called 5kyu on Codewars which takes about 100 hours solving JavaScript problems and about 100 hours of progress toward freeCodeCamp’s front end developer programme. Having passed both thresholds I’d highly recommend taking these first two steps (it’s pretty addictive actually – gamification for good), even for somewhat experienced developers. In between these exercises, I’d brush up on some theory; MITs open courseware on OOP in Python, David Flanagan’s “JavaScript, the definitive guide”, and some Douglas Crockford posts.

Better late than never

Now here’s the questions I was asked along with the answers I’ve come to understand. If an answer is missing then I’m working on it (not text book definitions but a practical understanding).

Core JavaScript
  1. What’s the difference between Null and Undefined?
    1. They’re different Types; Null being a special type of Object whereas Undefined is an ‘undefined’ type. Null is assigned whereas Undefined implies a declared variable has not been assigned a value
  2. What is a Closure in JavaScript?
    1. Closures consist of an environment and a function. I like how Crockford defines Closures. An inner function will have access to the variables and parameters of its outer function even after the outer function has returned. Closures can be used to implement Privileged methods in a JavaScript Class/Object which allow only indirect access to Private attributes (if at all) and so support data restriction and encapsulation.
Object Oriented Programming
  1. What is encapsulation?
    1. Enclosing and hiding the inner workings of an object (or class) and selectively exposing the methods to access (getters) and modify or mutate (setters) it. As an aside, it’s interesting to see how this is enforced across languages like C# (private variables), Python (@property), and JavaScript (closures).
  2. What is inheritance?
    1. Using the methods and attributes of a (parent) class as the foundation of a (child) class, so it helps with code reuse.
  3. Why favour composition over inheritance? (Design Pattern)
    1. Firstly, what is composition and how does it differ from inheritance?

Not asked but probably would have, to round off the big four tenants of OOP:

  • What is abstraction?
  • What is polymorphism?
    • Instances of Classes have different functionality while sharing the same interface. E.g. an instance of a Shape Class may take on one of many forms (e.g. it’s instance may be a triangle, square, etc.) but regardless of its internal state, they may all have a .draw() method available (as opposed to .drawCircle(), .drawSquare()). This helps with writing modular code.
Functional Programming
  1. What is composition?
    1. Similar to the mathematical idea of composition; that functions can be chained by taking the result of the first as input to the second, the result of the second as input to the third and so on.

Being able to sit down with someone who’s some years ahead of you in what you want to do is valuable. Passing comments during pair programming such as the unintuitive ‘do repeat yourself’ (so that a function has a single responsibility) have left an impression which influences how I think about code. It’s reinforced my understanding of why mentors are important, even if you have just such a fleeting experience.