Core functinality Flashcards

1
Q

anonymous functions

A

Anonymous functions are implemented with Closure class. They can be assigned to variables.

The parent scope of a closure is the function in which the closure was declared (not necessarily the function it was called from).

This is automatically bound, when function is declared inside of a Class.

Closure::bindTo - Create and return a new anonymous function with the same body and bound variables as this one, but possibly with a different bound object and a new class scope.

Also exists static anonymous functions. They don’t have $this, and also could no be bound to the object.

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

arrow functions (7.4+)

A

Arrow functions support the same features as anonymous functions, except that using variables from the parent scope is always automatic.

Arrow functions use by-value variable binding. A by-value binding means that it is not possible to modify any values from the outer scope. Anonymous functions can be used instead for by-ref bindings.

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