Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions resources/lecture-08/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function name_of_the_function(/* Input something*/) {
// Job_Holder_Lifecycle -> 'Bipon'
```

- Function code of above psuedocode
- Function code of the above pseudocode

```js
function sleep(name) {
Expand Down Expand Up @@ -173,11 +173,11 @@ function studentsLifecycle(name) {

- Invoke a function

```js
testFunction();
```
```js
testFunction();
```

There are some problems in above defined function. We can't use the function for any value. For this reason we need to use the parameters.
There are some problems with the defined function above. We can't use the function for any value. For this reason, we need to use the parameters.

```js
function testFunction(a = 10, b = 20) {
Expand All @@ -186,7 +186,7 @@ function testFunction(a = 10, b = 20) {
}
```

a and b are parameters. 10 and 20 are default values. If we don't pass any arguments in the function, it will take the default values as arguments. Now, what is arguments? Please see the below to learn that:
a and b are parameters. 10 and 20 are default values. If we don't pass any arguments in the function, it will take the default values as arguments. Now, what are arguments? Please see the below to learn that:

```js
testFunction(100, 200); // Here 100 and 200 are arguments
Expand Down Expand Up @@ -218,7 +218,7 @@ function times(a, b) {
console.log(r);
```

Function is a first class citizen. Because we can treat function as a value.
Function is a first-class citizen. Because we can treat function as a value.

- Benefits of a function treat as a value:

Expand All @@ -234,7 +234,7 @@ console.log(fn.toString());
fn();
```

- we can store function inside an object / array
- we can store functions inside an object / array

```js
const arr = [fn, testFunction];
Expand Down Expand Up @@ -277,7 +277,7 @@ const newFn = new Function(
console.log(newFn('HM Nayem'));
```

On the above code, we can pass arguments as many as we want. But last argument must be the function body. If we don't pass the body as last argument it will throw an error.
On the above code, we can pass arguments as much as we want. But the last argument must be the function body. If we don't pass the body as last argument it will throw an error.

More examples of function construction:

Expand Down