javascript - What is this communicating: my_var = my_var || 69 -
this question has answer here:
- what construct x = x || y mean? 11 answers
- set default parameter value javascript function 12 answers
i saw in javascript example
my_var = my_var || 69
i assume means check if my_var exists, if not set my_var 69. case? there documentation on this, hard represent google/so search, point me in direction of docs or duplicate qa?
(the example didn't use 69, that's me being crass)
easy enough try in js console.
var my_var my_var = my_var || 69 //69 var my_var = 5 my_var = my_var || 69 //5
you setting variable if carrying falsy value.
false
null
undefined
- the empty string
''
- the number 0
- the number nan
Comments
Post a Comment