Timeline for Is there a null-coalescing (Elvis) operator or safe navigation operator in javascript?
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 20, 2022 at 13:38 | comment | added | Jacques | String I tried this in the developer tools and one would have expected the result for "const result = a?.b?.c ?? 'Some other value';" to be "Some other value" since I haven't defined "a" but it just throws an "Uncaught ReferenceError: a is not defined". "Is not defined" = undefined right? | |
Nov 19, 2020 at 7:01 | comment | added | Max Waterman | You could add the way to do this with the [] syntax - from developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… , all of these are possible: obj.val?.prop obj.val?.[expr] obj.arr?.[index] obj.func?.(args) | |
Aug 22, 2020 at 19:37 | history | edited | jabacchetta | CC BY-SA 4.0 |
edited body
|
Aug 22, 2020 at 19:31 | history | edited | jabacchetta | CC BY-SA 4.0 |
added 2 characters in body; edited body
|
Aug 20, 2020 at 3:43 | comment | added | Emily |
a && a.b && a.c should be a && a.b && a.b.c . I can't edit that in myself because it's not a big enough change for SO to accept and I don't want to do the "change inconsequential things to make it to 6 characters" thing.
|
|
Jun 8, 2020 at 8:15 | comment | added | Yerke | This answer needs more upvotes. Nullish Coalescing Operator is now in stage 4. | |
Dec 20, 2019 at 10:31 | history | edited | jabacchetta | CC BY-SA 4.0 |
added 52 characters in body
|
Dec 20, 2019 at 10:23 | history | edited | jabacchetta | CC BY-SA 4.0 |
more examples
|
Dec 20, 2019 at 10:17 | history | edited | jabacchetta | CC BY-SA 4.0 |
remove inaccurate information
|
Dec 20, 2019 at 10:07 | history | edited | jabacchetta | CC BY-SA 4.0 |
update to not show bias towards one method or the other
|
Dec 20, 2019 at 9:58 | history | answered | jabacchetta | CC BY-SA 4.0 |