Correction from previous post with same name.❤
The difference between these two operators are, nullish(??) operator consider false, 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
note
: Even false is considered as true
🤷♀️
learning resources
🧡Scaler - India's Leading software E-learning
🧡w3schools - for web developers
Top comments (0)