├── strong_mode ├── vars.js ├── eqeq.js ├── empty.js ├── for.js ├── delete.js └── arguments.js ├── es6 ├── unicode │ └── unicode.js ├── subclass_array │ ├── iojs_v2_introduced_the_bug.js │ └── ShuffleArray.js ├── symbol_tostring │ └── symbol.js ├── rest_params │ └── rest.js ├── class │ └── animal.js ├── computed_property │ └── computedProps.js └── enhanced_object_literals │ └── person.js ├── buffer └── buffer.js └── README.md /strong_mode/vars.js: -------------------------------------------------------------------------------- 1 | "use strong"; 2 | 3 | var a = 'hoge'; 4 | -------------------------------------------------------------------------------- /strong_mode/eqeq.js: -------------------------------------------------------------------------------- 1 | 'use strong'; 2 | 3 | if ('a' == 'a') { 4 | } 5 | 6 | -------------------------------------------------------------------------------- /strong_mode/empty.js: -------------------------------------------------------------------------------- 1 | 'use strong'; 2 | 3 | if (true); 4 | console.log('hello'); 5 | -------------------------------------------------------------------------------- /es6/unicode/unicode.js: -------------------------------------------------------------------------------- 1 | console.log('\u{1F363}'); // 🍣 2 | console.log('\u{1F4A1}'); // 💡 3 | -------------------------------------------------------------------------------- /strong_mode/for.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 'use strong'; 3 | 4 | for (let k in [1, 2, 3]) { 5 | console.log(k); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /strong_mode/delete.js: -------------------------------------------------------------------------------- 1 | 'use strong'; 2 | 3 | let obj = { key: 'value'}; 4 | 5 | delete obj.key; 6 | 7 | console.log(obj); 8 | 9 | -------------------------------------------------------------------------------- /strong_mode/arguments.js: -------------------------------------------------------------------------------- 1 | 'use strong'; 2 | 3 | function some() { 4 | let args = Array.prototype.slice.call(arguments); 5 | } 6 | 7 | some(); 8 | 9 | -------------------------------------------------------------------------------- /es6/subclass_array/iojs_v2_introduced_the_bug.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | class Stack extends Array { } 3 | try { 4 | new Stack(); 5 | } catch (e) { 6 | console.log(e); 7 | } 8 | -------------------------------------------------------------------------------- /es6/symbol_tostring/symbol.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | class Cat { 3 | constructor() { 4 | this[Symbol.toStringTag] = 'Cat'; 5 | } 6 | } 7 | 8 | var cat = new Cat(); 9 | console.log(cat.toString()); // [object Cat] 10 | 11 | -------------------------------------------------------------------------------- /es6/rest_params/rest.js: -------------------------------------------------------------------------------- 1 | // Rest parameters 2 | function max(...args) { 3 | console.log(Array.isArray(args)) // true 4 | console.log(args.length) // 6 5 | var max = args.reduce(function(max, n) { 6 | return n > max ? n : max; 7 | }); 8 | return max; 9 | } 10 | var maxNum = max(5, 15, 10, 1, 4, 5); 11 | console.log(maxNum); // 15 12 | -------------------------------------------------------------------------------- /buffer/buffer.js: -------------------------------------------------------------------------------- 1 | const Buffer = require('buffer').Buffer; 2 | const ab = new ArrayBuffer(16); 3 | var buf = new Buffer(ab); // Buffer constructor accepts ArrayBuffer. 4 | 5 | console.log(buf instanceof Uint8Array); // true 6 | console.log(buf instanceof Buffer); // true 7 | 8 | buf.writeUInt32BE(0x61626364, 0); 9 | 10 | console.log(buf.toString()); //abcd 11 | -------------------------------------------------------------------------------- /es6/class/animal.js: -------------------------------------------------------------------------------- 1 | // strict mode needed 2 | 'use strict'; 3 | 4 | class Animal { 5 | constructor(name) { 6 | this.name = name 7 | } 8 | 9 | say() { 10 | // unimplemented 11 | } 12 | } 13 | 14 | class Cat extends Animal { 15 | say() { 16 | console.log(`${this.name} < meow`); 17 | } 18 | } 19 | 20 | var cat = new Cat('Mike'); 21 | cat.say(); 22 | -------------------------------------------------------------------------------- /es6/computed_property/computedProps.js: -------------------------------------------------------------------------------- 1 | var i = 0; 2 | var a = { 3 | ["foo" + ++i]: i, 4 | ["foo" + ++i]: i, 5 | ["foo" + ++i]: i 6 | }; 7 | 8 | console.log(a.foo1); // 1 9 | console.log(a.foo2); // 2 10 | console.log(a.foo3); // 3 11 | 12 | var param = 'size'; 13 | var config = { 14 | [param]: 12, 15 | ["mobile" + param.charAt(0).toUpperCase() + param.slice(1)]: 4 16 | }; 17 | 18 | console.log(config); 19 | -------------------------------------------------------------------------------- /es6/enhanced_object_literals/person.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | // class 3 | class Person { 4 | constructor(name, age) { 5 | this.name = name 6 | this.age = age 7 | } 8 | getInfo() { 9 | let name = this.name; 10 | let age = this.age; 11 | let nextAge = this.age + 1; 12 | // enhanced object literal 13 | return { 14 | name, 15 | age, 16 | nextAge 17 | }; 18 | } 19 | } 20 | 21 | var bob = new Person('bob', 15); 22 | 23 | console.log(bob.getInfo()); 24 | 25 | -------------------------------------------------------------------------------- /es6/subclass_array/ShuffleArray.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | class ShuffleArray extends Array { 3 | shuffle() { 4 | var l = this.length; 5 | var i; 6 | var t; 7 | while (l) { 8 | i = Math.floor(Math.random() * l--); 9 | t = this[l]; 10 | this[l] = this[i]; 11 | this[i] = t; 12 | } 13 | return this; 14 | } 15 | } 16 | 17 | var shuffleArray = new ShuffleArray(); 18 | shuffleArray.push(1, 2, 3, 4, 5, 6); 19 | console.log(shuffleArray.shuffle()); // shuffled [4, 6, 3, 1, 5, 2] 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # io.js v3.0 is released!!!!!!! 2 | 3 | io.js v3.0 new features. 4 | 5 | # ECMAScript 2015 - feature 6 | 7 | current V8 version 4.4 8 | previous V8 version 4.2 9 | 10 | If you would like to see the changes, see [the following url](https://gist.github.com/rvagg/1f115074cb3c890985bf) 11 | 12 | https://gist.github.com/rvagg/1f115074cb3c890985bf 13 | 14 | ## Computed property names 15 | 16 | Computed property names (`{['foo'+'bar']:'bam'}`) are shipped. 17 | No need to specify any `harmony-` flag. 18 | 19 | ```javascript 20 | var i = 0; 21 | var a = { 22 | ["foo" + ++i]: i, 23 | ["foo" + ++i]: i, 24 | ["foo" + ++i]: i 25 | }; 26 | 27 | console.log(a.foo1); // 1 28 | console.log(a.foo2); // 2 29 | console.log(a.foo3); // 3 30 | 31 | var param = 'size'; 32 | var config = { 33 | [param]: 12, 34 | ["mobile" + param.charAt(0).toUpperCase() + param.slice(1)]: 4 35 | }; 36 | 37 | console.log(config); 38 | ``` 39 | 40 | ``` 41 | $ iojs es6/computed_property/computedProps.js 42 | ``` 43 | 44 | ## unicode 45 | 46 | Unicode escape sequence (`\u{xxxxx}`) is shipped. 47 | No need to specify `--harmony` option. 48 | 49 | ```javascript 50 | console.log('\u{1F363}'); // 🍣 51 | console.log('\u{1F4A1}'); // 💡 52 | ``` 53 | 54 | ``` 55 | $ iojs es6/unicode/unicode.js 56 | ``` 57 | 58 | ## Array subclass 59 | 60 | class is already available, but previous version does not support built-in Array subclass. 61 | 62 | note: we should put 'use strict' on top. 63 | 64 | ```javascript 65 | // strict mode needed 66 | 'use strict'; 67 | class ShuffleArray extends Array { 68 | shuffle() { 69 | var l = this.length; 70 | var i; 71 | var t; 72 | while (l) { 73 | i = Math.floor(Math.random() * l--); 74 | t = this[l]; 75 | this[l] = this[i]; 76 | this[i] = t; 77 | } 78 | return this; 79 | } 80 | } 81 | 82 | var shuffleArray = new ShuffleArray(); 83 | shuffleArray.push(1, 2, 3, 4, 5, 6); 84 | console.log(shuffleArray.shuffle()); // shuffled [4, 6, 3, 1, 5, 2] 85 | ``` 86 | 87 | previous io.js is also available Array subclass. But they have an [issue](https://code.google.com/p/v8/issues/detail?can=2&q=3930&colspec=ID%20Type%20Status%20Priority%20Owner%20Summary%20HW%20OS%20Area%20Stars&id=3930). v8 fixed the problem. 88 | 89 | ## Spread operator 90 | 91 | Now, we can use `Spread operator (...) `. 92 | But we need to specify `--es_staging` arguments. 93 | 94 | The spread operator allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) are expected. 95 | 96 | ```javascript 97 | // Spread operator 98 | var arr1 = [0, 1, 2]; 99 | var arr2 = [3, 4, 5]; 100 | arr1.push(...arr2); // we can use ... 101 | console.log(arr1); 102 | ``` 103 | 104 | ``` 105 | $ node --es_staging es6/spread_operator/spread.js 106 | ``` 107 | 108 | ## Rest parameters 109 | 110 | Rest parameters (`function(...args) {}`) are implemented in staging behind the `--es-staging` flag. 111 | 112 | ```javascript 113 | // Rest parameters 114 | function max(...args) { 115 | // rest parameter is not Array-like object, that is just array. 116 | console.log(Array.isArray(args)) // true 117 | console.log(args.length) // 6 118 | 119 | var max = args.reduce(function(max, n) { 120 | return n > max ? n : max; 121 | }); 122 | return max; 123 | } 124 | 125 | var maxNum = max(5, 15, 10, 1, 4, 5); 126 | console.log(maxNum); // 15 127 | ``` 128 | 129 | ``` 130 | $ iojs --es_staging es6/rest_params/rest.js 131 | ``` 132 | 133 | 134 | # REPL saves history by default 135 | 136 | REPL gets a history file. 137 | In previous version, repl needs to specify `NODE_REPL_HISTORY_FILE`. 138 | But current version, repl saves history by default. 139 | 140 | ``` 141 | $ iojs 142 | > var fs = require('fs'); 143 | # Ctrl-D 144 | $ iojs 145 | > var fs = require('fs'); # push up button 146 | ``` 147 | 148 | # Buffer is subclass of Uint8Array 149 | 150 | ```javascript 151 | const Buffer = require('buffer').Buffer; 152 | const ab = new ArrayBuffer(16); 153 | var buf = new Buffer(ab); // Buffer constructor accepts ArrayBuffer. 154 | 155 | console.log(buf instanceof Uint8Array); // true 156 | console.log(buf instanceof Buffer); // true 157 | 158 | buf.writeUInt32BE(0x61626364, 0); 159 | 160 | console.log(buf.toString()); //abcd 161 | ``` 162 | 163 | # Remove smalloc and Deprecate freelist 164 | 165 | `smalloc` module is removed. 166 | `freelist` module is now deprecated. 167 | 168 | # Want to know more?? 169 | 170 | please check the following issue. 171 | 172 | https://github.com/nodejs/io.js/blob/master/CHANGELOG.md#2015-08-04-version-300-rvagg 173 | https://github.com/nodejs/io.js/wiki/Breaking-Changes#300-from-2x 174 | --------------------------------------------------------------------------------