I guess you would have want to use the ternary operator to make it more readable, instead of adding the || and && which are harder to understand: the ternary operator accepts a nicer and more predictable form of (value, ifTrue, ifFalse) instead of constructing it on your own with boolean operator magic
constget=(store,key)=>Reflect.has(window[store],key)?JSON.parse(window[store][key]):newError(`Key ${key} not found`)
I guess this is readable enough, but I'll probably use the "verbose" one (it really depends on the project standards): I like early returns, or "guard" clauses - can help debugging by understanding that you can stop evaluating the function in your head 😺
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I guess you would have want to use the ternary operator to make it more readable, instead of adding the
||
and&&
which are harder to understand: the ternary operator accepts a nicer and more predictable form of(value, ifTrue, ifFalse)
instead of constructing it on your own with boolean operator magicI guess this is readable enough, but I'll probably use the "verbose" one (it really depends on the project standards): I like early returns, or "guard" clauses - can help debugging by understanding that you can stop evaluating the function in your head 😺