User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » New in JavaScript Page [1]  
CaelNCSU
All American
6883 Posts
user info
edit post

I noticed Node and Chrome allow const so it got me looking into some other new features in the pipe. Turns out Firefox now supports most of this.

Constants:
const A_CONSTANT = 1; // reassignment doesn't work

Destructuring:
[a, b] = [1 ,2] //var a = 1, b = 2

Block Scoping:
if(1) { let x = 1; } // typeof x === 'undefined';

Generators & Lazy Evaluation:
function* one() {
yield 123;
return 1;
}
var generator = one();
generator.next(); // 123
generator.next(); // 1

List Comprehensions:
var colorArr = [{color:'blue'}, {color:'red'}];
var yieldsFromGenerator = [x for(x of generator())]; // [ 123 ]
var filteredRed = [x for(x of colorArr) if(x.color =='red')] // only contains red item

Looks like JavaScript sucks infinitely less now. Hopefully those features make it into the wild by years end.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.7#Using_JavaScript_1.7



[Edited on February 5, 2014 at 12:27 PM. Reason : a]

2/5/2014 12:25:12 PM

Kris
All American
36908 Posts
user info
edit post

[code]PUT CODE HERE[/code]

2/5/2014 4:13:55 PM

lewisje
All American
9196 Posts
user info
edit post

I can barely wait for it to support goto

2/5/2014 4:33:52 PM

CaelNCSU
All American
6883 Posts
user info
edit post

Constants:

const A_CONSTANT = 1; // reassignment doesn't work


Destructuring:
[a, b] = [1 ,2] //var a = 1, b = 2


Block Scoping:

if(1) {
let x = 1;
}
// typeof x === 'undefined';


Generators & Lazy Evaluation:

function* one() {
yield 123;
return 1;
}
var generator = one();
generator.next(); // 123
generator.next(); // 1


List Comprehensions:

var colorArr = [{color:'blue'}, {color:'red'}];
var yieldsFromGenerator = [x for(x of generator())]; // [ 123 ]
var filteredRed = [x for(x of colorArr) if(x.color =='red')] // only contains red item


[Edited on February 5, 2014 at 4:50 PM. Reason : a]

2/5/2014 4:49:48 PM

spöokyjon

18617 Posts
user info
edit post

Wouldn't block scoping break a bunch of existing JS code?

2/6/2014 12:51:58 AM

Ernie
All American
45943 Posts
user info
edit post

Block scoping is possible by using let, which was new to JS 1.7. All blocks are not scoped. That would be... insane.

2/6/2014 9:13:39 AM

shoot
All American
7611 Posts
user info
edit post

bttt
I want to conquer it ASAP to make some money.

5/30/2014 2:33:34 PM

lewisje
All American
9196 Posts
user info
edit post

Keep in mind that "JavaScript 1.7" and so on refer to Mozilla's implementation of the language, which has some extensions not in the ECMAScript standard and therefore not expected to be implemented by other browsers (although some of them are); with that said, everything listed in the OP is also in the soon-to-be-ratified ES6 standard, and you can see which browsers support each new feature here: https://kangax.github.io/compat-table/es6/

The site also has tables for ES5 and the non-standard features of various JS engines, and for more general info. on compatibility with features of the Web platform, look here: http://caniuse.com/

6/1/2014 8:14:25 AM

 Message Boards » Tech Talk » New in JavaScript Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.