Functions Flashcards

1
Q

does all functions return a value?

A

Yes, by default it is undefined…. if the function return something, then it might be anything else.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to access an argument of a function that does not declare any parameter?

A

via arguments[]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an Immediately Invoked Function Expression (IIFE)? How to declare it?

A

it is a function that is called right after declared. Declared via:

(function () {code here}();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Closure?

A

It is when the function returns a function. e.g:

function sum(a, b) {
  return function suminternally() {
   return a+b;
}
}
let mysum = sumb(1,2);
mysumn(); //returns 3
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When Arrow Functions were introduced?

A

ES6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why using arrow functions?

A

Shorter syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to declare an arrow function with and without params?

A
let af = param => {return param };
af('asd') // returns 'asd'
let af = () => {return 'asd'};
af() // returns 'asd'
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to declare an arrow function that takes two or more params?

A

let af = (a, b) => {return a+b}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Are arrow functions similar to c#’s lambda expressions?

A

Yes, same thing but with different names

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what happens to the this keyword when using arrow functions?

A

They are available but with a different scope (not the object scope). it is likely to be the Window object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly