Questions tagged [ecmascript-harmony]

ECMAScript Harmony is the code name for proposals aiming to extend the current ECMA-262 specification.

ECMAScript Harmony is the code name for proposals aiming to extend the current ECMA-262 specification and to form the new . It names the agreed design trajectory of post-ES5 editions. It will include syntactic extensions, but the changes will be more modest than ECMAScript 4 in both semantic and syntactic innovation.

Packages, namespaces, and early binding from ECMAScript 4 are no longer included for planned releases, and don't live under the roof of Harmony.

References

  1. ECMAScript - Wikipedia
  2. ECMAScriptHarmony - ECMAScript.org
239 questions
44
votes
2 answers

Immediate function using JavaScript ES6 arrow functions

Does anyone know how to write an immediate function using ES6 arrow syntax? Here's the ES3/5 way of doing it: (function () { //... }()); I've tried the following but get an unexpected token error on the last line. (() => { //... }()); You can…
d13
  • 9,421
  • 11
  • 33
  • 39
43
votes
8 answers

ECMAScript:Harmony / ES6 to JavaScript compiler

After reading Peter's article on JavaScript I noticed Brendan Eich stated that one the goals for Harmony is to be a better target for to-JavaScript compilers. There are currently two popular compilers with some vague ES:Harmony…
Raynos
  • 156,883
  • 55
  • 337
  • 385
37
votes
5 answers

Map using tuples or objects

I'm trying to use the new (ES6) Map objects in order to represent a map between properties and a value. I have objects in a form similar to: {key1:value1_1,key2:value2_1},..... {key1:value1_N,key2:value2_N} I want to group them based on both their…
Benjamin Gruenbaum
  • 246,787
  • 79
  • 474
  • 476
35
votes
9 answers

Is it possible to reset an ECMAScript 6 generator to its initial state?

Given the provided (very simple) generator, is it possible to return the generator back to its original state to use again? var generator = function*() { yield 1; yield 2; yield 3; }; var iterable = generator(); for (let x of iterable)…
dvlsg
  • 4,568
  • 1
  • 25
  • 34
29
votes
4 answers

ES5 Object.assign equivalent

I wanted to do something which is very straight-forward using Object.assign. var firstObj = {name : "Saba H.", rollNo : 1}; var secondObj = {college : "WCE"}; var wholeObj = Object.assign(firstObj, secondObj); console.log(wholeObj); // {name :…
Saba Hassan
  • 2,898
  • 1
  • 17
  • 32
28
votes
3 answers

ES7 Getting result from an array of promises using await generator

Given an array of promises, what's the idiomatic way to get the results in ES7? Here's what I want to do: async function getImports() { let imports = [System.import('./package1.js'), System.import('./package2.js')]; let promises = await*…
Matt K
  • 4,314
  • 3
  • 19
  • 33
27
votes
2 answers

unexpected strict mode reserved word -- yield? Node v0.11, harmony, es6

Trying to use a new ES6 based node.js ODM for Mongo (Robe http://hiddentao.github.io/robe/) Getting "unexpected strict mode reserved word" error. Am I dong something wrong here? test0.js "use strict"; // Random ES6 (works) { let a = 'I am declared…
Robert Taylor
  • 309
  • 1
  • 3
  • 7
26
votes
5 answers

Converting Singleton JS objects to use ES6 classes

I'm using ES6 with the Webpack es6-transpiler per my article here: http://www.railsonmaui.com/blog/2014/10/02/integrating-webpack-and-the-es6-transpiler-into-an-existing-rails-project/ Does it make any sense to convert two Singleton objects to use…
justingordon
  • 11,553
  • 9
  • 64
  • 111
23
votes
1 answer

Why can functions be called without parentheses when using template strings?

I have a simple logging function: function log(str) { console.log('logged: ', str); } If I call it without parentheses (currently using Chrome's dev tools) and pass in a template string, like this: log`foo` The output is: logged: ["foo", raw:…
23
votes
10 answers

JavaScript ES6: Test for arrow function, built-in function, regular function?

Is there an elegant way to tell Harmony's slim arrow functions apart from regular functions and built-in functions? The Harmony wiki states that: Arrow functions are like built-in functions in that both lack .prototype and any [[Construct]]…
20
votes
5 answers

Enable Harmony Proxies in nodejs

Is it possible to enable EcmaScript 6 Harmony Proxies in nodejs? If so, what are the pros and cons? And is there any documentation on how to use them? Thanks !
Alexandre Kirszenberg
  • 33,587
  • 8
  • 84
  • 70
19
votes
2 answers

ES6 global import

What is the best way to import some modules in all of the files of the project, so I don't have to write stuff like: import React from 'react'; import Reflux from 'reflux'; import reactMixin from 'react-mixin'; in almost every single file?
Victor Marchuk
  • 10,195
  • 10
  • 36
  • 62
19
votes
1 answer

When will ES6 be available in IE?

This is a legitimate question if you really know the answer or can provide some information. Firefox and Chrome are continually working to include many of the features in ES Harmony... My question is really 2 parts: Does anyone know when ES6 will…
Nathan Wall
  • 9,698
  • 3
  • 22
  • 47
16
votes
1 answer

Creating a regular weak-reference in Javascript using WeakMaps

I am trying to do the obvious thing with WeakMaps: I want to create a weak reference. In particular, I want to have a list of event-listeners without that list influencing the life of the listener. So I was very excited to find WeakMaps, until I…
Malvolio
  • 38,966
  • 24
  • 87
  • 125
16
votes
2 answers

SyntaxError: Unexpected Identifier (Generators in ES6)

I came up with this simple experiment after reading the documentation on generators from MDN: var nodes = { type: 'root', value: [ { type: 'char', value: 'a' }, { type: 'char', value: 'b' }, { type: 'char', value: 'c'…
Alix Axel
  • 141,486
  • 84
  • 375
  • 483
1
2
3
15 16