ecmascript-harmony

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

浪尽此生 提交于 2019-12-02 22:13:45
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 inside an anonymous block'; } var Robe = require('robe'); // :( var db1 = yield Robe.connect('127.0.0.1'); Run it: C:\TestWS>node --version v0.11.10 C:\TestWS>node --harmony test0.js C:\TestWS\test0.js:12 var db1 = yield Robe.connect('127.0.0.1'); ^^^^^ SyntaxError: Unexpected strict mode reserved word at exports.runInThisContext (vm.js:69:16) at

ES5 Object.assign equivalent

我怕爱的太早我们不能终老 提交于 2019-12-02 17:09:27
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 H.", rollNo : 1, college : "WCE"} As Object.assign is part of ECMAScript6 harmony proposal and not supported across many browsers, is it possible to do with ES5? If not then is there any micro library? In underscore.js you can use like, _.extend(firstObj, secondObj); In jQuery, you can use, $.extend({},firstObj,secondObj); In pure javascipt, you

How to make an iterator out of an ES6 class

天大地大妈咪最大 提交于 2019-12-02 16:29:58
How would I make an iterator out of an ES6 class in the same manner as JS1.7 SomeClass.prototype.__iterator__ = function() {...} syntax? [EDIT 16:00] The following works: class SomeClass { constructor() { } *[Symbol.iterator]() { yield '1'; yield '2'; } //*generator() { //} } an_instance = new SomeClass(); for (let v of an_instance) { console.log(v); } WebStorm flags *[Symbol.iterator]() with a 'function name expected' warning directly following the asterix, but otherwise this compiles and runs fine with Traceur. (Note WebStorm does not generate any errors for *generator() .) Define a suitable

Will it be possible to find out an object's class and module in ecmascript-harmony

我只是一个虾纸丫 提交于 2019-12-02 10:21:50
问题 When reading the ecmascript-harmony specification I cannot see anything about inspecting instances/objects in regards to find out information about their class and module. What I want to do is to be able to inspect a javascript object (that is an instance of a es6 harmony class) and find out: the name of the class it was instantiated from the name of the module the class was defined in the name of possible super classes and their modules Does anybody know if this will be possible in es6? If

Why I can not start harmony mode by “node --harmony test.js” from command line?

怎甘沉沦 提交于 2019-12-02 08:23:45
The problem is: longhao33@hePC:~$ node --harmony test.js /home/longhao33/test.js:1 (function (exports, require, module, __filename, __dirname) { let str = 'es666666666666'; ^^^ SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:413:25) at Object.Module._extensions..js (module.js:452:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:475:10) at startup (node.js:117:18) at node.js:951:3 But "let" is

What is the difference between ECMAScript 6 and ECMAScript Harmony?

本秂侑毒 提交于 2019-12-01 19:53:07
问题 I thought that they were the same thing for a while, but I often see phrasing in blogs or in answers here that seems to imply that there is a difference between the two. Even SO has two distinct tags, but their description doesn't show any clear difference. I searched around for a bit and it only added to the confusion as it seems that I am not the only one who's unsure about what means what. Is there an official definition for both of these terms, perhaps defined by Ecma International

What is the difference between ECMAScript 6 and ECMAScript Harmony?

谁说胖子不能爱 提交于 2019-12-01 18:41:28
I thought that they were the same thing for a while, but I often see phrasing in blogs or in answers here that seems to imply that there is a difference between the two. Even SO has two distinct tags, but their description doesn't show any clear difference. I searched around for a bit and it only added to the confusion as it seems that I am not the only one who's unsure about what means what. Is there an official definition for both of these terms, perhaps defined by Ecma International themselves? If not, is there at least a commonly accepted definition? As @JamesAllardice already said in the

Promise chaining: Use result from previous promise in next then callback [duplicate]

孤人 提交于 2019-12-01 09:33:56
This question already has an answer here: How do I access previous promise results in a .then() chain? 17 answers I'm using straight ES6 Promises (with the es6-promise polyfill library) and I'm running into a problem with accessing results from previous promises in chained ones. This problem is identical in the context of Angular/Q, but I'm dissatisfied with the answer and wanted to see if there's a better way: How to access result from the previous promise in AngularJS promise chain? Consider the code snippet below: Student.find().then(function(student) { return HelpRequest.findByStudent

Map() is not defined in Google Chrome

六眼飞鱼酱① 提交于 2019-12-01 06:44:15
I've been searching for an answer but I'm only getting results regarding the Google maps API. I'm trying to use a map in JavaScript to map an integer to a string. Everything is working fine in Firefox but in chrome I get an error message in the console: Uncaught ReferenceError: Map is not defined Below is a piece of reference code: var NameMap; var DistanceMap; function FillMaps(){ NameMap = new Map(); DistanceMap = new Map(); NameMap.set(01, "Araba/Álava"); } function CheckName(_field){ var value = document.getElementsByName(_field.name).item(0).value; var location = value.charAt(0) + value

Map() is not defined in Google Chrome

情到浓时终转凉″ 提交于 2019-12-01 05:04:39
问题 I've been searching for an answer but I'm only getting results regarding the Google maps API. I'm trying to use a map in JavaScript to map an integer to a string. Everything is working fine in Firefox but in chrome I get an error message in the console: Uncaught ReferenceError: Map is not defined Below is a piece of reference code: var NameMap; var DistanceMap; function FillMaps(){ NameMap = new Map(); DistanceMap = new Map(); NameMap.set(01, "Araba/Álava"); } function CheckName(_field){ var