Comment

Comment by shittyanalogy

ECMAScript 6 is a mess

Now there's a completely new function syntax that doesn't use parens and has different scope rules

    var odds = evens.map(v => v + 1);
Enhanced object literals:

    // Computed (dynamic) property names
    [ 'prop_' + (() => 42)() ]: 42
what?? So it uses parens if there are no params, but not otherwise?

Template Strings:

    `In JavaScript this is
     not legal.`
Seriously another String delimiter?

    `Hello ${name}, how are you ${time}?`
Why aren't we just using #{} like everyone else?

    // Construct an HTTP request prefix is used to interpret the replacements and construction

    GET`http://foo.org/bar?a=${a}&b=${b}...
What??

Destructuring:

    var [a, , b] = [1,2,3];
Is that seriously just whitespace and another comma?

Splats (spreads?)

    f(...[1,2,3]) == 6
... means destructure?

This is not readable code:

    let fibonacci = {
      [Symbol.iterator]() {
        let pre = 0, cur = 1;
        return {
          next() {
            [pre, cur] = [cur, pre + cur];
            return { done: false, value: cur }
          }
        }
      }
    }
    
    for (var n of fibonacci) {
      // truncate the sequence at 1000
      if (n > 1000)
        break;
      print(n);
    }

Symbols without a literal syntax: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Jesus Christ.

Unicode:

    "𠮷".length == 2
Awesome, still wrong.

Modules are cool. Promises are cool. Tail call optimization is cool.

This is not readable code:

    // Proxying a normal object
    var target = {};
    var handler = {
      get: function (receiver, name) {
        return `Hello, ${name}!`;
      }
    };
    
    var p = new Proxy(target, handler);
    p.world === 'Hello, world!';
ES6 is a mess. Javascript just got harder.
parent shittyanalogy 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton