This content originally appeared on DEV Community and was authored by aryan015
Correction from previous post with same name.❤
The difference between these two operators are, nullish(??) operators consider 0 and "",[],{} as a true.
Only null and undefined is considered as false.
const obj = {
name:'aryan khandelwal'
age:26
}
obj?.['name'] //aryan khandelwal // only access 'name' when objest is defined.
obj||obj['name'] //aryan khandelwal
This content originally appeared on DEV Community and was authored by aryan015
aryan015 | Sciencx (2024-06-17T16:47:23+00:00) Nullish coalescing vs Logical || by aryan. Retrieved from https://www.scien.cx/2024/06/17/nullish-coalescing-vs-logical-by-aryan-2/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.