using if vs using ||

Edit on GitHub

Setup

Tests

  • using if

    var a = undefined;
    if (a) {
      a = '';
    }
  • using ||

    var a = undefined;
    a = a || '';