You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Q. Show the most common ways of creating functions in JavaScript
143
143
144
-
-The functions are most commonly created as function statements, function expression and arrow functions
144
+
-Functions are most commonly created using function statements, function expressions and arrow functions
145
145
- Function statements get hoisted unlike function expressions
146
146
147
147
```js
@@ -223,9 +223,9 @@ Arrow functions are also called fat arrow functions
223
223
224
224
### Q. Write a program where hoisting can be visualized
225
225
226
-
- The function statement and variable declared with `var` are accessible before it appears in the code
226
+
- The function statement and variable declared with `var` are accessible before they appear in the code
227
227
- Declarations are put into memory before it executes any code segment that allows us to use a function before you declare it in your code
228
-
- In hoisting the hoisted items are accessible in the scope it is declared
228
+
- In hoisting the hoisted items are accessible in the scope they are declared in
229
229
- Function expressions do not get hoisted
230
230
231
231
```js
@@ -244,7 +244,7 @@ var nonHoistedFunc = function () {
244
244
245
245
###### Notes
246
246
247
-
Hoisting was thought up as a general way of thinking about how execution contexts work in JavaScript. In reality, code does not get hoisted, but affect is seen due to compilation and execution phases followed by JavaScript compiler
247
+
Hoisting was thought up as a general way of thinking about how execution contexts work in JavaScript. In reality, the code does not get hoisted, but the effect is seen due to compilation and execution phases followed by JavaScript compiler
248
248
249
249
###### References
250
250
@@ -283,8 +283,8 @@ Hoisting was thought up as a general way of thinking about how execution context
283
283
284
284
### Q. Create an IIFE which receives arguments and executes
285
285
286
-
- Arguments can be passed normally to an IIFE like we pass to while calling regular functions
287
-
- Multiple arguments can be passed similar to function invokation with arguments
286
+
- Arguments can be passed in the same way as when calling a regular functions
287
+
- Multiple arguments can be passed similar to function invocation with arguments
288
288
289
289
```js
290
290
(functionIIFE(param1, param2) {
@@ -317,8 +317,8 @@ var randomNumber = (function () {
317
317
318
318
### Q. Write a function which can return multiple values from a function
319
319
320
-
-Function in general is designed to return a single value.
321
-
- Generators are special type of functions which returns iterator which in turn can be used to send & receive values.
320
+
-In general functions are designed to return a single value.
321
+
- Generators are a special type of functions which return an iterator which in turn can be used to send & receive values.
322
322
323
323
```js
324
324
functionmultipleValueReturnFunc() {
@@ -366,7 +366,7 @@ Array and object are used in the programs to contain multiple values
366
366
367
367
<br />
368
368
369
-
### Q. Write a function which can set default value to the parameters of function when an argument is not passed. Also show how to use exisiting parameters to set the value of another parameter
369
+
### Q. Write a function which can set default values to the parameters of function when an argument is not passed. Also show how to use exisiting parameters to set the value of another parameter
370
370
371
371
- Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed
372
372
@@ -444,12 +444,12 @@ The context inside the function can be accessed using `this` keyword
444
444
445
445
<br />
446
446
447
-
### Q. Show the usage of function which can used as a constructor
447
+
### Q. Show the usage of a function which can be used as a constructor
448
448
449
-
-Function can be used to like a constructor by calling it with a`new` keyword
450
-
-Constructor function is a normal function but generally used to create object and may also have functions in its prototype
451
-
-Constructor function is generally preferred to start with Uppercase letter which is not mandatory
452
-
- The return from the constructor function is new object created which is accessed with `this` inside the function
449
+
-A function can be used like a constructor by calling it with the`new` keyword
450
+
-A constructor function is a normal function but generally used to create an object and may also have functions in its prototype
451
+
-A constructor function is generally preferred to start with a Uppercase letter which is not mandatory
452
+
- The return from the constructor function is a new object created which is accessed with `this` inside the function
453
453
- Constructor function can return an explicit object as well
454
454
455
455
```js
@@ -481,9 +481,9 @@ Constructor function can be called without new keyword as well, which executes t
481
481
482
482
<br />
483
483
484
-
### Q. Show the procedure of creating object using a factory function
484
+
### Q. Show the procedure of creating an object using a factory function
485
485
486
-
- Any function which is not a class or constructor that returns an object without a new keyword is known as factory function
486
+
- Any function which is not a class or constructor that returns an object without a new keyword is known as a factory function
487
487
- A normal function which can be modified to return an object which can be called by passing arguments
488
488
489
489
```js
@@ -512,8 +512,8 @@ const user = factoryFunc("admin", "password");
512
512
513
513
### Q. Achieve prototypal inheritance using functions to create objects in JavaScript
514
514
515
-
- 2 functions can be used create objects with constructor call to the functions
516
-
- The prototype of child function is connected with parent function to achieve the inheritance behavior
515
+
- 2 functions can be used to create objects with constructor call to the functions
516
+
- The prototype of the child function is connected with the parent function to achieve the inheritance behavior
517
517
518
518
```js
519
519
functionparent(name) {
@@ -544,7 +544,7 @@ console.log(pk.getName());
544
544
545
545
###### Notes
546
546
547
-
Solution is one of the known way of achieving prototypal inheritance, but is not the only way to achieve it.
547
+
The solution is one of the known ways of achieving prototypal inheritance, but it is not the only way to achieve it.
0 commit comments