We have small but important difference between default value of destructed property and ||
const{foo="bar"}=baz
In this case runtime compiler (as I know) checks value only on undefined and because of this some falsy value like false or '' is not been replaced to default value "bar"
But in other case
constfoo=baz.foo||"bar"
|| checks first operand on any possible falsy value and if we have .foo like null then variable will been equals to "bar"
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.
Good article, thanks ! :)
But one moment
We have small but important difference between default value of destructed property and
||In this case runtime compiler (as I know) checks value only on
undefinedand because of this some falsy value likefalseor''is not been replaced to default value"bar"But in other case
||checks first operand on any possible falsy value and if we have.foolikenullthen variable will been equals to"bar"