17 ms·
The "=" operator always returns the value on the right side, and it always processes the right side before the left side. Therefore: 1 - this.mutation = this.
by dentemple 8y ago
The "=" operator always returns the value on the right side, and it always processes the right side before the left side.
Therefore:
1 - this.mutation = this.get // returns this.get
2 - this.query = <return value of this.mutation = this.get, which is this.get>
3 - this.patch = <return value of this.query = this.mutation = this.get, which is this.get>
n - and so on...
Essentially, it's setting 6 different properties all to the same value.
---
EDIT: Here's the same concept, but in a different context...
function fibonacci(num, memo = {}) {
if (num <= 1) return 1;
if (memo[num]) return memo[num];
return memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo);
}
On the return line, the right-to-left property of "=" forces the extreme right to be processed first. It returns the recursive call.
Then, the return value of this recursive call gets saved to "memo[num]".
Finally, the return value of "memo[num] = fibonacci(...) + fibonacci(...)", which is still the same return value from the recursive call, gets saved to the function return.