Common Javascript Interview Question and Answer

Common Javascript Interview Question and Answer

  1. What is the difference between undefined and null?
  • Both null and undefined are falsy values.
  • undefine == null //true, undefine === null //false
// ES5 Regular function
let double = function(n) { return n * 3}
alert( double(3) ); // 9
// ES6 Arrow function
let double = n => n * 3;
alert( double(3) ); // 9
  • Simplifies initialization and saves memory: no need to add many handlers.
  • Less code: when adding or removing elements, no need to add/remove handlers.
  • DOM modifications: we can mass add/remove elements with innerHTML and the like.
  • The document object is available immediately.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store