toggling variable inside Module Pattern using function declaration vs function expression

I have a module pattern with a variable setting the currentPlayer to 1. I use a function expression to toggle that variable If I run game.currentPlayer it logs 1, I then run game.toggleCurrentPlayer(), and it doesn’t change currentPlayer as intended, it still returns 1. However, changing the toggleCurrentPlayer() function using this, seems to be able to change the variable successfully I know function declarations and function expressions have different meanings for the keyword this, but why would the toggleCurrentPlayer() only work properly with the this keyword and not be able to set the variable on its own? Answer When the

Rxjs nested subscribe with multiple inner subscriptions

Original promise based code I’m trying to rewrite: I’m trying to figure a way how to avoid the nested subscriptions anti-pattern in the following scenario: What would be the correct ‘RxJS way’ to do this? Answer That seems pretty strange to me. You’re creating new subscription for each child every time parentResult arrives. Even though those eventually indeed will be destroyed (assuming onDestroy$ implementation is correct), seems wrong. You probably want withLatestFrom(parent$) and three separate pipes for each child. It might look something like: child1$.pipe(takeUntil(globalDeath$), withLatestFrom(parent$)).subscribe(([childResult, parentResult]) => …). Not sure if my JS is correct, can’t test it at