Let's look at an example.
This code snippet checks if a value is neither
null
nor undefined
using the
||
operator.
Since we do not have a grade
key in the student
object,
value of student.grade
will be undefined, and
therefore we get the output
"Student grade must be provided".
We would get the same output
if the value of the
student.grade
variable was null
.