javascript - What is this communicating: my_var = my_var || 69 -


this question has answer here:

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.

falsy values in js are:

  1. false
  2. null
  3. undefined
  4. the empty string ''
  5. the number 0
  6. the number nan

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -