i saw some folks saying this runs all 4 operations but that isnt true right? the key [operation] is defining the condition for the code block within cases resulting in only the code matching the condition being executed? Essentially replacing switch(operation) if i understand it correctly.
This is a very interesting way to use the concept of an object in JavaScript!
So cool bro
No, it actually calls all 4 operations, due to the fact that the object initialization has to resolve it's properties during runtime
so by calling cases[operation], you're just returning 1 of 4 already calculated operations
impressive
Very clever
yeah
Impressive)))))))))
i saw some folks saying this runs all 4 operations but that isnt true right? the key [operation] is defining the condition for the code block within cases resulting in only the code matching the condition being executed? Essentially replacing switch(operation) if i understand it correctly.
Interesting way.
I was doing 'case' and it was appearing an error curious why this was happening but when puttting 'cases' it appeared correct?
Yeah; in fact, this particular approach relies on that.
it will change the input array :)
Clever, great!
Object Literal?
Edit: Oh wait, it is actually operating the other 3 as well, even if they are not selected? XD JS is weird.
Loading more items...