This question already has an answer here:
When something is undefined there are the following two ways of giving a default value.
I have been wondering for a while what the difference between this:
return {
name: user.name || 'Raul'
}
and this:
return {
name: user.name ? user.name : 'Raul'
}
Is there any I should use over another, or side effects I should be aware of?
Aucun commentaire:
Enregistrer un commentaire