Skip to content
Advertisement

Tag: logical-or

When should I use ?? (nullish coalescing) vs || (logical OR)?

Related to Is there a “null coalescing” operator in JavaScript? – JavaScript now has a ?? operator which I see is in use more frequently. Previously most JavaScript code used ||. In what circumstances will ?? and || behave differently? Answer The OR operator || uses the right value if left is falsy, while the nullish coalescing operator ?? uses

Advertisement