Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> FYI, you don't need to use `this`

You do if you use react.

> omit `;` or use `==`.

Mistakes are made all the time.

> Also JavaScript is commutative as long as FP64 is.

Nope.

$ node > [] + {} '[object Object]' > {} + [] 0

> Out of curiosity, what's the pain with removing an index using `splice(index, 1)`?

Finding it. Remembering it. Getting it right. Reading it back.

Remove the 3rd and get it in Python:

res = a.pop(4)

In JS:

var res = a[4]; a.splice(4, 1); // usually a comment to remind you that you pop

It's verbose, ugly, unintuitive.

It's like this : https://xkcd.com/1168/

But for JS.



> $ node > [] + {} '[object Object]' > {} + [] 0

Note that that has nothing to do with math. It has to do with braces being used for both blocks and object literals.

Of course, I'm not too happy about the automatic coercion of everything and anything to either strings or numbers, but if you want consistency, try parentheses, or a + [], where a = {}.


Haven't used React but I'm sceptical. In what case do you need to use `this`?

The only time I believe I've used this was maybe using a class? Which is shit so why would I want to do that anyway?

Okay, so there are footguns. Don't use them, use a linter, problem solved.

That doesn't look like math. What are you saying exactly?

What's your problem with let res = a.splice(4, 1) ? I don't understand really, the method name and extra parameter?


fyi splice returns the slice you remove, and ES6 allows array deconstruction so you could just use `var [res] = a.splice(4, 1);`.


>> FYI, you don't need to use `this`

> You do if you use react.

You can use functional components.




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

Search: