diff --git a/front-end/interview-questions.md b/front-end/interview-questions.md index 9630684c..97d30471 100644 --- a/front-end/interview-questions.md +++ b/front-end/interview-questions.md @@ -713,7 +713,7 @@ A closure is the combination of a function and the lexical environment within wh They can be used in IIFEs to encapsulate some code within a local scope so that variables declared in it do not leak to the global scope. -``` +```js (function() { // Some code here. })(); @@ -721,7 +721,7 @@ They can be used in IIFEs to encapsulate some code within a local scope so that As a callback that is used once and does not need to be used anywhere else. The code will seem more self-contained and readable when handlers are defined right inside the code calling them, rather than having to search elsewhere to find the function body. -``` +```js setTimeout(function () { console.log('Hello world!'); }, 1000); @@ -729,7 +729,7 @@ setTimeout(function () { Arguments to functional programming constructs or Lodash (similar to callbacks). -``` +```js const arr = [1, 2, 3]; const double = arr.map(function (el) { return el * 2; @@ -923,7 +923,7 @@ These days, [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) i Yes. Handlebars, Underscore, Lodash, AngularJS and JSX. I disliked templating in AngularJS because it made heavy use of strings in the directives and typos would go uncaught. JSX is my new favourite as it is closer to JavaScript and there is barely and syntax to be learnt. Nowadays, you can even use ES2015 template string literals as a quick way for creating templates without relying on third-party code. -``` +```js const template = `