Re:JavaScript for People Who Hate JavaScript
by gvx on Wednesday August 09, 2017 @09:22AM
(#14968450)
> $ 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 = {}.
Re:JavaScript for People Who Hate JavaScript
by cerved on Wednesday August 09, 2017 @01:43PM
(#14971702)
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?
Re:JavaScript for People Who Hate JavaScript
by Guillaume86 on Wednesday August 09, 2017 @07:47AM
(#14967611)
fyi splice returns the slice you remove, and ES6 allows array deconstruction so you could just use `var [res] = a.splice(4, 1);`.
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.