简体   繁体   中英

Destructuring assignment in Parse.com CloudCode

I'm trying to use destructuring assignment in Cloud Code on Parse.com, but when I run the code, the compiler gives me this error:

Result: ReferenceError: Invalid left-hand side in assignment

My code is this:

[a, b] = foo();

And for example foo is implemented as follows:

function foo()
{ 
   return [2, 3];
}

In a lot of browsers this code works fine but... in Parse Cloud Code I still have this error.

How can I use destructuring assignment here? PS: I would prefer to use only an istruction to make this.

Here is ES6 compatibility table: http://kangax.github.io/compat-table/es6/

As you can see, destructuring is supported in Firefox (SpiderMonkey) and Safari (JavaScriptCore), but not in Chrome or Node (v8). Parse Cloud Code most likely runs on Node or bare v8, so that's it.

You've got only one solution: transpilers, like Traceur or 6to5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM