Hacker News new | ask | show | jobs
by eccenux 2071 days ago
class A defines a let variable. It's how the standard define it.

You can replace A with: A = class {...}

This works with any browser.

BTW. In Firefox there is a multi line editor. With code completion. I actually find more convenient to test large code fragments in fox because of that.

1 comments

Good tip, thanks, but it means that code written like

  class A {}
has a huge difference from code written like

  A = class {}
In classical JavaScript consider how small the difference is between

  function foo () {}
and

  foo = function () {}
Function hoisting only works for the "function foo(){}" form so there's a difference but they intuitively work essentially the same and either form works well when experimenting in the console. If enough rules like "class A {} is very different from A = class {}" are piled onto JavaScript it's going to become like C++, a language so complex that people would rather learn a simpler language so they can focus on the complexities of their actual problem space rather than the complexities of their language. A new language called Zig is now trending upward because a growing number of programmers would rather have a language they can 100% understand after a reasonable time investment rather than a language like C++ where even after a 20 year career with it and implementing portions of a compiler for it you still get painfully surprised by some obscure rule interaction you never dreamed to imagine possible.