Show Menu

JS interview Cheat Sheet by

javascript

Higher order funtions

Functions that accept other functions as their arguments.
EG .map or .filter
Can help to write code quicker with less bugs due to code reuse

Destru­cturing

Break and object or array into variables
Great for options objects like ajax options
Can be put into the function declar­ation params with optional values

Closures

Function body has access to variables defined outside its scope
Useful in callbacks. For example passing a value into an ajax success. Var can be defined before the call and still accessed from the success

Currying

Currying is when a function, instead of taking all arguments at one time, takes the first one and returns a new function that takes the second one and returns a new function which takes the third one, and so forth, until all arguments have been fulfilled.
The idea is that a function can pass through an applic­ation and gradually receive the parameters it needs
funct­ion­('a­rg1­')(­'ar­g2'­)('­arg3')
 

Recursion

When a function calls its self until it doesn't
An example would be when you have a bunch categories form a DB and you want to map all the children into a tree structure.

Factory functions

Factories - Functions that create objects and return them.
Better to use than classes for Compos­ition!
Inheri­tance encourages you to predict the future of your classes (bad) it will most likely change though out the project

Compos­ition

Compos­ition is simply when a class is composed of other classes; or to say it another way, an instance of an object has references to instances of other objects.
Is better as we dont have to think of all our classes at the start and when we inevitably need to change them we can with ease
Eg A robot dog needs the bark from the dog class but not the sleep.

Two types of function

Declar­ation - function something (){}
Hoisted to the global scope
Expression - var something = function (){}
Good to use for passing function into other function. EG the ajax success or a .map
 

OO Javascript

(OOP) refers to using self-c­ont­ained pieces of code to develop applic­ations
Building applic­ations with objects allows us to adopt some valuable techni­ques, namely, Inheri­tance

Objects


Objects can be thought of as the main actors­(th­ings) in an applic­ation
Every component in JavaScript is an Object, including Functions, Strings, and Numbers
We normally use object literals or constr­uctor functions to create objects.

Encaps­ulation

refers to enclosing all the functi­ona­lities of an object within that object so that the object’s internal workings (its methods and proper­ties) are hidden from the rest of the applic­ation.
his allows us to abstract or localize specific set of functi­ona­lities on objects.
A way to do this would be wrap everything in an Immedi­ate­ly-­Invoked Function Expression IIFE - a way to implement the module pattern. Allows private methods and data, defining an API for public use.

Inheri­tance

refers to an object being able to inherit methods and properties from a parent object

Download the JS interview Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/wkerswell_js-interview.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          AngularJS Cheat Sheet
          JavaScript Cheat Sheet
          jasmine JS testing Cheat Sheet