JavaScript in Plain English

New JavaScript and Web Development content every day. Follow to join our 3.5M+ monthly readers.

Follow publication

The JavaScript Cheatsheet you need in 2021

Stefania Simon
JavaScript in Plain English
9 min readOct 26, 2020

--

I'm pretty sure I'm not the only one who ran into some uncomfortable technical questions during an interview and felt like I knew what was going on but couldn't really explain it.

I've been working on this summary of questions and concepts for a while now and selected the 20 most challenging ones. Enjoy!

What is the difference between Arrow and Regular Functions?

  • This value (context): in a regular function, the value of this has nothing to do with the class on which it was defined; instead, it depends on the object that it was called upon; inside an arrow function this value always equals the this value from the outer function
  • Constructors: regular functions can easily construct objects, while an arrow function cannot be used as a constructor
  • Arguments object: is a special array-like object containing the list of arguments with which the function has been invoked, inside an arrow function the arguments object is resolved lexically: it accesses arguments from the outer function
  • Implicit return: regular functions use the return expression statement — otherwise it will just return undefined, while with arrow functions, if they contain one expression and the function’s curly braces are missing, then the expression is implicitly returned
  • Read more

How does This work?

  • this keyword refers to an object, that object which is executing the current bit of javascript code
  • Every javascript function while executing has a reference to its current execution context, called this — execution context means here is how the function is called
  • To understand this keyword, only we need to know how, when and from where the function is called, does not matter how and where function is declared or defined
  • Read more & see examples

What are callbacks and closures?

  • Callback: a function which is accessible by another function and invoked after the first function — if that first function completed
  • Read more about callbacks

--

--

Published in JavaScript in Plain English

New JavaScript and Web Development content every day. Follow to join our 3.5M+ monthly readers.

Written by Stefania Simon

A curious mind wondering and sharing experiences.

Responses (9)

Write a response