Hacker Newsnew | past | comments | ask | show | jobs | submit | joeblow99's commentslogin

"loophole" is a word for "a completely legal tax maneuver I don't like"


Worse, it's often a work for "a completely legal tax provision I don't understand."


Use const for all of your references; avoid using var. If you must mutate references, use let instead of var.

In my 15 years of programming javascript I've never once seen this matter.


That's because let and const where officially introduced in JavaScript this year, see the JavaScript standard ES6 (or ES2015).


// bad const items = new Array();

// good const items = [];

They obviously spent a lot of time on this guide, lots of investor dollars, and it's of almost no use.


Making sure everyone within your company writes the same style code, makes it more readable and easier to find bugs. You can also start doing automatic linting and hinting. On top of that, they made the top on hacker news which will help finding new devs.


Imagine this:

a = new Array(10);

b = [10];

alert(a[0]);

alert(b[0]);

Do you know the difference?

This is just one reason. Also [] will be faster. Just google the differences and why [] is recommended to use.


  > new Array('a')
  ["a"]
  > new Array(2, 3)
  [2, 3]
  > new Array(2)
  [undefined, undefined]
  > new Array(2.3)
  RangeError: invalid array length
  > new Array(2.3, 4.5)
  [2.3, 4.5]
The Array constructor is really bogus. It switches to a different mode if a single number is passed.

ES6 added `Array.of` for this reason:

  > Array.of()
  []
  > Array.of(1)
  [1]
  > Array.of(1, 2)
  [1, 2]
I don't really think it's needed though. Spread and rest already take care of the common use cases.


// bad const item = new Object();

// good const item = {};

Literally useless differentiation.


Seems pretty useful to me. If I see "new Object()", I know the code was written by someone who doesn't know JS very well, so I should look more carefully for bugs.


That's why they call it Style Guide. You know - Style?


Same functionality, less characters. This also helps being consistent.


Hah, "literally"


some kind of queuing as well


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: