Skip to content

Commit 26123d1

Browse files
committed
Update README.md
1 parent 3f59490 commit 26123d1

File tree

1 file changed

+9
-31
lines changed

1 file changed

+9
-31
lines changed

README.md

+9-31
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
| 190.|[Explain how prototypal inheritance works?](#q-explain-how-prototypal-inheritance-works)|
204204
| 191.|[Example of Prototypal Inheritance?](#q-example-of-prototypal-inheritance)|
205205
| 192.|[What do you think of AMD vs CommonJS?](#q-what-do-you-think-of-amd-vs-commonjs)|
206-
| 193.|[Explain why the following doesn't work as an IIFE: `function foo(){ }();`. What needs to be changed to properly make it an IIFE?](#q-explain-why-the-following-doesn-t-work-as-an-iife-function-foo-what-needs-to-be-changed-to-properly-make-it-an-iife)|
206+
| 193.|[Explain why the following does not work as an IIFE: `function foo(){ }();`. What needs to be changed to properly make it an IIFE?](#q-explain-why-the-following-does-not-work-as-an-iife-function-foo-what-needs-to-be-changed-to-properly-make-it-an-iife)|
207207
| 194.|[What is the difference between a variable that is: `null`, `undefined` or undeclared? How would you go about checking for any of these states?](#q-what-is-the-difference-between-a-variable-that-is-null-undefined-or-undeclared-how-would-you-go-about-checking-for-any-of-these-states)|
208208
| 195.|[Can you describe the main difference between a `.forEach` loop and a `.map()` loop and why you would pick one versus the other?](#q-can-you-describe-the-main-difference-between-a-foreach-loop-and-a-map-loop-and-why-you-would-pick-one-versus-the-other)|
209209
| 196.|[What is a typical use case for anonymous functions?](#q-what-is-a-typical-use-case-for-anonymous-functions)|
@@ -281,24 +281,12 @@
281281
| 268.|[Explain how `this` works in JavaScript?](#q-explain-how-this-works-in-javascript)|
282282
| 269.|[Explain how prototypal inheritance works?](#q-explain-how-prototypal-inheritance-works)|
283283
| 270.|[What do you think of AMD vs CommonJS?](#q-what-do-you-think-of-amd-vs-commonjs)|
284-
| 271.|[Explain why the following doesnot work as an IIFE: `function foo(){ }();`. What needs to be changed to properly make it an IIFE?](#q-explain-why-the-following-doesn-t-work-as-an-iife-function-foo-what-needs-to-be-changed-to-properly-make-it-an-iife)|
285-
| 272.|[What is the difference between a variable that is: `null`, `undefined` or undeclared? How would you go about checking for any of these states?](#q-what-is-the-difference-between-a-variable-that-is-null-undefined-or-undeclared-how-would-you-go-about-checking-for-any-of-these-states)|
286284
| 273.|[What is a closure, and how/why would you use one?](#q-what-is-a-closure-and-how-why-would-you-use-one)|
287-
| 274.|[Can you describe the main difference between a `.forEach` loop and a `.map()` loop and why you would pick one versus the other?](#q-can-you-describe-the-main-difference-between-a-foreach-loop-and-a-map-loop-and-why-you-would-pick-one-versus-the-other-1)
288-
| 275.|[What is a typical use case for anonymous functions?](#q-what-is-a-typical-use-case-for-anonymous-functions-1)
289-
| 276.|[How do you organize your code? (module pattern, classical inheritance?)](#q-how-do-you-organize-your-code-module-pattern-classical-inheritance-1)
290-
| 277.|[What is the difference between host objects and native objects?](#q-what-is-the-difference-between-host-objects-and-native-objects-1)
291-
| 278.|[Difference between: `function Person(){}`, `var person = Person()`, and `var person = new Person()`?](#q-difference-between-function-person-var-person-person-and-var-person-new-person-1)
292-
| 279.|[What is the difference between `.call` and `.apply`?](#q-what-is-the-difference-between-call-and-apply-1)
293-
| 280.|[Explain `Function.prototype.bind`?](#q-explain-functionprototypebind-1)
294-
| 281.|[When would you use `document.write()`?](#q-when-would-you-use-documentwrite-1)
295-
| 282.|[What is the difference between feature detection, feature inference, and using the UA string?](#q-what-is-the-difference-between-feature-detection-feature-inference-and-using-the-ua-string-1)
285+
| 274.|[Can you describe the main difference between a `.forEach` loop and a `.map()` loop and why you would pick one versus the other?](#q-can-you-describe-the-main-difference-between-a-foreach-loop-and-a-map-loop-and-why-you-would-pick-one-versus-the-other)|
296286
| 283.|[Have you ever used JavaScript templating? If so, what libraries have you used?](#q-have-you-ever-used-javascript-templating-if-so-what-libraries-have-you-used)|
297287
| 284.|[Explain "hoisting" in JavaScript?](#q-explain-hoisting-in-javascript)|
298-
| 285.|[What is the difference between an "attribute" and a "property"?](#q-what-is-the-difference-between-an-attribute-and-a-property-1)
299-
| 286.|[Why is extending built-in JavaScript objects not a good idea?](#q-why-is-extending-built-in-javascript-objects-not-a-good-idea-1)
300-
| 287.|[Difference between document `load` event and document `DOMContentLoaded` event?](#q-difference-between-document-load-event-and-document-domcontentloaded-event-1)
301-
| 288.|[What is the difference between `==` and `===`?](#q-what-is-the-difference-between-and-1)
288+
| 285.|[What is the difference between an "attribute" and a "property"?](#q-what-is-the-difference-between-an-attribute-and-a-property)|
289+
| 287.|[Difference between document `load` event and document `DOMContentLoaded` event?](#q-difference-between-document-load-event-and-document-domcontentloaded-event)
302290
| 289.|[What is JSON and its common operations?](#q-what-is-json-and-its-common-operations)|
303291
| 290.|[What is the purpose of array slice method?](#q-what-is-the-purpose-of-array-slice-method)|
304292
| 291.|[What is the purpose of array splice method?](#q-what-is-the-purpose-of-array-splice-method)|
@@ -2807,7 +2795,7 @@ var height = window.innerHeight
28072795
The conditional (ternary) operator is the only JavaScript operator that takes three operands which acts as a shortcut for if statement.
28082796
```javascript
28092797
var isAuthenticated = false;
2810-
console.log(isAuthenticated ? 'Hello, welcome' : 'Sorry, you are not authenticated'); //Sorry, you are not authenticated
2798+
console.log(isAuthenticated ? 'Hello, welcome' : 'Sorry, you are not authenticated');
28112799
```
28122800
<div align="right">
28132801
<b><a href="#">↥ back to top</a></b>
@@ -4054,16 +4042,16 @@ I'm glad that with ES2015 modules, that has support for both synchronous and asy
40544042
<b><a href="#">↥ back to top</a></b>
40554043
</div>
40564044
4057-
#### Q. ***Explain why the following doesn't work as an IIFE: `function foo(){ }();`. What needs to be changed to properly make it an IIFE?***
4045+
#### Q. ***Explain why the following does not work as an IIFE: `function foo(){ }();`. What needs to be changed to properly make it an IIFE?***
40584046
40594047
IIFE stands for Immediately Invoked Function Expressions. The JavaScript parser reads `function foo(){ }();` as `function foo(){ }` and `();`, where the former is a *function declaration* and the latter (a pair of parentheses) is an attempt at calling a function but there is no name specified, hence it throws `Uncaught SyntaxError: Unexpected token )`.
40604048
40614049
Here are two ways to fix it that involves adding more parentheses: `(function foo(){ })()` and `(function foo(){ }())`. Statements that begin with `function` are considered to be *function declarations*; by wrapping this function within `()`, it becomes a *function expression* which can then be executed with the subsequent `()`. These functions are not exposed in the global scope and you can even omit its name if you do not need to reference itself within the body.
40624050

4063-
You might also use `void` operator: `void function foo(){ }();`. Unfortunately, there is one issue with such approach. The evaluation of given expression is always `undefined`, so if your IIFE function returns anything, you can't use it. An example:
4051+
You might also use `void` operator: `void function foo(){ }();`. Unfortunately, there is one issue with such approach. The evaluation of given expression is always `undefined`, so if your IIFE function returns anything, you can not use it. An example:
40644052
4065-
```
4066-
// Don't add JS syntax to this code block to prevent Prettier from formatting it.
4053+
```js
4054+
// Do not add JS syntax to this code block to prevent Prettier from formatting it.
40674055
const foo = void function bar() { return 'foo'; }();
40684056

40694057
console.log(foo); // undefined
@@ -6685,16 +6673,6 @@ The main difference between `.forEach` and `.map()` is that `.map()` returns a n
66856673
<b><a href="#">↥ back to top</a></b>
66866674
</div>
66876675
6688-
#### Q. ***What is the difference between host objects and native objects?***
6689-
6690-
Native objects are objects that are part of the JavaScript language defined by the ECMAScript specification, such as `String`, `Math`, `RegExp`, `Object`, `Function`, etc.
6691-
6692-
Host objects are provided by the runtime environment (browser or Node), such as `window`, `XMLHTTPRequest`, etc.
6693-
6694-
<div align="right">
6695-
<b><a href="#">↥ back to top</a></b>
6696-
</div>
6697-
66986676
#### Q. ***Have you ever used JavaScript templating? If so, what libraries have you used?***
66996677
67006678
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 favorite as it is closer to JavaScript and there is barely any syntax to learn. Nowadays, you can even use ES2015 template string literals as a quick way for creating templates without relying on third-party code.

0 commit comments

Comments
 (0)