Array Comprehensions - NON-STANDARD

Share this video with your friends

Send Tweet

Array Comprehensions didn't make the ES6 cut. You probably shouldn't use them ;)

See comments.

Eric
Eric
~ 9 years ago

Removed from Babel 6! D:

Weng Koon Wong
Weng Koon Wong
~ 8 years ago

HOw to make this work in command line?

TestMacBook (master *+) babeltest $ npm run build

babeltest@1.0.0 build /Users/TestMacBook/Documents/egghead/babeltest babel src -d lib

SyntaxError: src/index.js: Unexpected token (29:14) 27 | ] 28 |

29 | let emails = [for({email, firstName} of people) if(firstName === "Melinda") email] | ^ 30 | 31 | 32 | console.log(emails);

npm ERR! Darwin 15.5.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build" npm ERR! node v6.2.1 npm ERR! npm v3.9.3 npm ERR! code ELIFECYCLE npm ERR! babeltest@1.0.0 build: babel src -d lib npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the babeltest@1.0.0 build script 'babel src -d lib'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the babeltest package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! babel src -d lib npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs babeltest npm ERR! Or if that isn't available,