News for hackers. Stuff that matters.
Re:CIL (.NET bytecode) to WebAssembly compiler by tracker1 on Thursday September 03, 2015 @05:42AM (#10164016)
Is the argument a dictionary?

    if (a instanceof Array) ...

    // or polyfill
    Array.isArray = Array.isArray || function(a) { 
      return a instanceof Array; 
    };
Object.keys can be cleanly shimmed without braking older browsers. You can always shim in the behavior you want, as long as you don't need IE7 support.

    Object.prototype.values = function() {
      var instance = this;
      return Object.keys(this).map(function(key){
        return instance[key];
      });
    }
Replacing globally in a string

    console.log("I lose and lose again, not even close.".replace(/\blose\b/g, "win"));
If you're using ES6 or node-style modules, you shouldn't generally mess with global state, unless you are polyfilling new features. Promises (bluebird), fetch, etc...

Understanding falsy values is a core part of learning JS, as is coercion... no it isn't perfect, but there are flaws in any language you can bring up.

As to a function assigned to a variable vs a function declaration, well again that's part of learning the language.... Being able to use functions as first class expressions is a very powerful feature, that frankly works pretty well.

Of the features missing from JS proper, an isolated invokable web-workers scenario with plain, side effect free functions/modules would be a great start (not the current way via secondary script).

That said, most of your complaints are things that are easier to work around, or simply things that you learn with the language. It's not that different from learning warts in Python (which is better than many), C#, Java or anything else.

Re:CIL (.NET bytecode) to WebAssembly compiler by lqdc13 on Thursday September 03, 2015 @06:06AM (#10164085)
Regarding Arrays:

   var iframe = document.createElement('iframe');
   document.body.appendChild(iframe);
   xArray = window.frames[window.frames.length-1].Array;
   var a = new xArray(1,2,3);
   >> a instanceof Array;
   << false
   >> a
   << Array [ 1, 2, 3 ]
   >> Object.prototype.toString.call(a) === "[object Array]"
   << true
All I'm saying is there are way too many such things that you have to keep in mind.
Re:CIL (.NET bytecode) to WebAssembly compiler by tracker1 on Thursday September 03, 2015 @07:13AM (#10164268)
See `Array.isArray` which you can polyfill however you like ... Beyond that, if you bring primitives from another frame, you kind of get what you deserve. Most likely you should check for not a string, but has `length` property that is a Number and use `Array.from` with your conditions, especially with arguments or dom collections.

Most likely when working across frames, you should use messaging, unless you're doing something truly hokey... In either case, working across frames like that is akin to poking into the memory of one process from another. It's bound to have issues...

I don't think this is something that WebAssembly would allow you to do in the first place...