News for hackers. Stuff that matters.
Re:CIL (.NET bytecode) to WebAssembly compiler by kolme on Thursday September 03, 2015 @04:42AM (#10163885)
> Checking whether a passed argument is an array or a dict

Luckily solved in ES2015:

Array.isArray(thing)

The toString trick is pretty outdated, in ES5 you can also do:

thing instanceof Array

> (perhaps not js itself, but how it is used) Leaking DOM nodes are a thing

Definitely not JS itself, it's easy to create circular references between JS objects and DOM elements. It's just the way the DOM is (poorly) designed and the way it interacts with JS.

> for each (var myVar in myObject)

That's not even standard, just a Mozilla "dialect". I don't think that's supported by any engines other than SpiderMonkey and predecessors.

Re:CIL (.NET bytecode) to WebAssembly compiler by gsnedders on Thursday September 03, 2015 @08:14AM (#10164466)
>The toString trick is pretty outdated, in ES5 you can also do:

> thing instanceof Array

instanceof is ES3.

> That's not even standard, just a Mozilla "dialect". I don't think that's supported by any engines other than SpiderMonkey and predecessors.

To quote MDC:

> The for each...in statement is deprecated as the part of ECMA-357 (E4X) standard. E4X support has been removed, but for each...in will not be disabled and removed because of backward compatibility considerations. Consider using for...of instead. (Please refer to bug 791343.)

Re:CIL (.NET bytecode) to WebAssembly compiler by lqdc13 on Thursday September 03, 2015 @09:38AM (#10164840)
So now we have ...

    for each (var x in a) ...  <<Firefox only??>>
    for (var x of a) ...  <<ES6>>
    for (var x in a) ...
    a.forEach(callback[, thisArg])
Knowing JS, each of them have their own quirks probably.
Re:CIL (.NET bytecode) to WebAssembly compiler by kolme on Thursday September 03, 2015 @09:46AM (#10164892)
Yes:

for each (...) -> It's not supported anywhere, so forget it.

for (var x in a) -> x is the key, so it's kind of inconvenient. You have to watch out for inherited properties/methods so one should check for a.hasOwnProperty(x).

for (var x of a) -> It has mostly no gotchas. Only poor browser support.

.forEach only works with arrays and from ES5 on. You have the good old "this"/scope gotcha.

Re:CIL (.NET bytecode) to WebAssembly compiler by realityking on Thursday September 03, 2015 @06:08AM (#10164088)
Array.isArray is already in ES5 and can be used in any reasonably modern browser (meaning IE9+)