Skip to content

Commit 380ece5

Browse files
authored
Merge pull request sadanandpai#46 from alex1s1/patch-1
Update functions-concepts.md
2 parents ea94aa5 + 9393a28 commit 380ece5

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

challenges/functions-concepts.md

+27-27
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func(); // Hello
2525

2626
###### Notes
2727

28-
Function can also be stored in variables like other values in JavaScript
28+
Functions can also be stored in variables like other values in JavaScript
2929

3030
###### References
3131

@@ -34,10 +34,10 @@ Function can also be stored in variables like other values in JavaScript
3434

3535
<br />
3636

37-
### Q. Write a function which executes another function recieved as an argument
37+
### Q. Write a function which executes another function received as an argument
3838

39-
- Functions can be passed as arguments to another functions
40-
- Passing the function as argument will pass its reference hence no parenthesis
39+
- Functions can be passed as arguments to another function
40+
- Passing the function as an argument will pass its reference hence no parenthesis
4141

4242
```js
4343
function callbackExecutor(callback) {
@@ -62,9 +62,9 @@ callbackExecutor(callbackFunc); // Callback function executed
6262

6363
### Q. Create a function having no parameters declared and print all the arguments passed to it
6464

65-
- When a function is invoked the arguments passed to it are accessible using the defualt object called "arguments"
66-
- Numbers starting from 0 is set as key of the object "arguments" corresponding to each argument in the order
67-
- `arguments` object will have length property as well which gives count of arguments passed
65+
- When a function is invoked the arguments passed to it are accessible using the default object called "arguments"
66+
- Numbers starting from 0 are set as keys of the object "arguments" corresponding to each argument in the order
67+
- The `arguments` object will have a length property as well which gives count of arguments passed
6868

6969
```js
7070
function func() {
@@ -120,7 +120,7 @@ function func(a, b, c) {
120120

121121
<br />
122122

123-
### Q. Design a function which can recieve variable number of arguments in parameters and print them
123+
### Q. Design a function which can receive a variable number of arguments in parameters and print them
124124

125125
```js
126126
function varArgsFunc(...params) {
@@ -141,7 +141,7 @@ varArgsFunc("Hello", ",", "World", "!!!");
141141

142142
### Q. Show the most common ways of creating functions in JavaScript
143143

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
145145
- Function statements get hoisted unlike function expressions
146146

147147
```js
@@ -223,9 +223,9 @@ Arrow functions are also called fat arrow functions
223223

224224
### Q. Write a program where hoisting can be visualized
225225

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
227227
- 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
229229
- Function expressions do not get hoisted
230230

231231
```js
@@ -244,7 +244,7 @@ var nonHoistedFunc = function () {
244244

245245
###### Notes
246246

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
248248

249249
###### References
250250

@@ -283,8 +283,8 @@ Hoisting was thought up as a general way of thinking about how execution context
283283

284284
### Q. Create an IIFE which receives arguments and executes
285285

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
288288

289289
```js
290290
(function IIFE(param1, param2) {
@@ -317,8 +317,8 @@ var randomNumber = (function () {
317317

318318
### Q. Write a function which can return multiple values from a function
319319

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.
322322

323323
```js
324324
function multipleValueReturnFunc() {
@@ -366,7 +366,7 @@ Array and object are used in the programs to contain multiple values
366366

367367
<br />
368368

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
370370

371371
- Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed
372372

@@ -444,12 +444,12 @@ The context inside the function can be accessed using `this` keyword
444444

445445
<br />
446446

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
448448

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
453453
- Constructor function can return an explicit object as well
454454

455455
```js
@@ -481,9 +481,9 @@ Constructor function can be called without new keyword as well, which executes t
481481

482482
<br />
483483

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
485485

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
487487
- A normal function which can be modified to return an object which can be called by passing arguments
488488

489489
```js
@@ -512,8 +512,8 @@ const user = factoryFunc("admin", "password");
512512

513513
### Q. Achieve prototypal inheritance using functions to create objects in JavaScript
514514

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
517517

518518
```js
519519
function parent(name) {
@@ -544,7 +544,7 @@ console.log(pk.getName());
544544

545545
###### Notes
546546

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.
548548

549549
###### References
550550

0 commit comments

Comments
 (0)