0
let x = process.argv[2] || "abc";

I am new to javascript. I don't think || is a boolean OR operator here. What does this line mean? Why using OR on some strings? Does this mean if process.argv[2] is null, then assign "abc" to x?

Ziyang Zhang
  • 3,084
  • 10
  • 30
  • 37
  • This is a boolean `or` gate. If the contents of `process.argv[2]` is falsy (`process.argv[2] == false`) then it will assign `"abc"` to x instead. – Emil S. Jørgensen Jul 03 '17 at 13:38
  • 1
    You inspired from this (asked few min ago) ? https://stackoverflow.com/questions/44885901/how-does-the-var-foo-foo-idiom-in-javascript-work – Suresh Atta Jul 03 '17 at 13:39
  • [Logical_operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Logical_operators) – hindmost Jul 03 '17 at 13:39

0 Answers0