| OLD | NEW |
| (Empty) |
| 1 <!-- This is feature markdown template | |
| 2 ## Header | |
| 3 | |
| 4 **Usage Example:** | |
| 5 | |
| 6 ``` js | |
| 7 | |
| 8 ``` | |
| 9 | |
| 10 **Documentation:** [link]() | |
| 11 | |
| 12 **Discussion Notes / Link to Thread:** | |
| 13 | |
| 14 hyphen-hyphen-hyphen (change to actual hyphen) | |
| 15 | |
| 16 --> | |
| 17 | |
| 18 | |
| 19 <style type="text/css"> | |
| 20 .doc { | |
| 21 font-size: 16px; | |
| 22 } | |
| 23 | |
| 24 .doc h2[id] { | |
| 25 line-height: 20px; | |
| 26 font-size: 16px; | |
| 27 } | |
| 28 | |
| 29 .doc h2 > code { | |
| 30 font-size: 16px; | |
| 31 font-weight: bold; | |
| 32 } | |
| 33 | |
| 34 .feature-container { | |
| 35 background-color: #e8eef7; | |
| 36 border: 1px solid #c3d9ff; | |
| 37 margin-bottom: 5px; | |
| 38 border-radius: 5px; | |
| 39 } | |
| 40 | |
| 41 .feature-container > h2 { | |
| 42 cursor: pointer; | |
| 43 background-color: #c3d9ff; | |
| 44 margin: 0; | |
| 45 padding: 5px; | |
| 46 border-radius: 5px; | |
| 47 } | |
| 48 | |
| 49 .feature-container > *:not(h2){ | |
| 50 display: none; | |
| 51 padding: 0px 10px; | |
| 52 } | |
| 53 | |
| 54 .feature-container.open > *:not(h2){ | |
| 55 display: block; | |
| 56 } | |
| 57 </style> | |
| 58 | |
| 59 <script> | |
| 60 document.addEventListener("DOMContentLoaded", function(event) { | |
| 61 // Move all headers and corresponding contents to an accordion container. | |
| 62 document.querySelectorAll('h2[id]').forEach(function(header){ | |
| 63 var container = document.createElement('div'); | |
| 64 container.classList.add('feature-container'); | |
| 65 header.parentNode.insertBefore(container, header); | |
| 66 | |
| 67 // Add all the following siblings until it hits an <hr> | |
| 68 var ele = header; | |
| 69 while(ele && ele.tagName !== 'HR') { | |
| 70 var nextEle = ele.nextElementSibling; | |
| 71 container.append(ele); | |
| 72 ele = nextEle; | |
| 73 } | |
| 74 | |
| 75 // Add handler to open accordion on click. | |
| 76 header.addEventListener('click', () => { | |
| 77 header.parentNode.classList.toggle('open'); | |
| 78 }); | |
| 79 }); | |
| 80 | |
| 81 // Then remove all <hr>s since everything's accordionized. | |
| 82 document.querySelectorAll('hr').forEach(function(ele){ | |
| 83 ele.parentNode.removeChild(ele); | |
| 84 }); | |
| 85 }); | |
| 86 </script> | |
| 87 | |
| 88 [TOC] | |
| 89 | |
| 90 # ES6 Support In Chromium | |
| 91 | |
| 92 This is a list of new/updated features in ES6 specs that is being considered to | |
| 93 be supported for Chromium development. | |
| 94 | |
| 95 >**TBD:** Do we want to differenciate allow/ban status between subprojects? If | |
| 96 so, how to denote? | |
| 97 | |
| 98 >**TBD:** Cross platform-build support? | |
| 99 | |
| 100 You can propose changing the status of a feature by sending an email to | |
| 101 chromium-dev@chromium.org. Include a short blurb on what the feature is and why | |
| 102 you think it should or should not be allowed, along with links to any relevant | |
| 103 previous discussion. If the list arrives at some consensus, send a codereview | |
| 104 to change this file accordingly, linking to your discussion thread. | |
| 105 | |
| 106 >Some descriptions and Usage examples are from [kangax](https://kangax.github. | |
| 107 io/compat-table/es6/) and [http://es6-features.org/](http://es6-features.org/) | |
| 108 | |
| 109 # Allowed Features | |
| 110 | |
| 111 The following features are allowed in Chromium development. | |
| 112 | |
| 113 ## `Promise` | |
| 114 | |
| 115 Built-in representation of a value that might be determined asynchronously, | |
| 116 relieving developers from "callback hell". | |
| 117 | |
| 118 **Usage Example:** | |
| 119 | |
| 120 ``` js | |
| 121 function promiseA() { | |
| 122 return new Promise((resolve, reject) => setTimeout(resolve, 100)); | |
| 123 } | |
| 124 | |
| 125 function promiseB() { | |
| 126 return new Promise((resolve, reject) => setTimeout(resolve, 200)); | |
| 127 } | |
| 128 | |
| 129 function promiseC() { | |
| 130 return new Promise((resolve, reject) => setTimeout(resolve, 300)); | |
| 131 } | |
| 132 | |
| 133 Promise.all([promiseA(), promiseB(), promiseC()]).then(([a, b, c]) => { | |
| 134 someFunction(a, b, c); | |
| 135 }); | |
| 136 ``` | |
| 137 | |
| 138 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 139 /#sec-promise-objects) | |
| 140 | |
| 141 **Discussion Notes:** Feature already extensively used prior to creation of | |
| 142 this document. | |
| 143 | |
| 144 --- | |
| 145 | |
| 146 # Banned Features | |
| 147 | |
| 148 The following features are banned for Chromium development. | |
| 149 | |
| 150 # Features To Be Discussed | |
| 151 | |
| 152 The following features are currently disallowed. See the top of this page on | |
| 153 how to propose moving a feature from this list into the allowed or banned | |
| 154 sections. | |
| 155 | |
| 156 ## `let` (Block-Scoped Variables) | |
| 157 | |
| 158 Declare variable that exists within the block scope. `let` can generally be | |
| 159 used to replace `var` but `let` in global scope, unlike `var`, does not | |
| 160 introduce a property on the global object. | |
| 161 | |
| 162 **Usage Example:** | |
| 163 | |
| 164 ``` js | |
| 165 // This will make all buttons output "3". | |
| 166 for(var i = 0; i < 3; i++) { | |
| 167 buttons[i].onclick = function() { | |
| 168 console.log(i); | |
| 169 }; | |
| 170 } | |
| 171 | |
| 172 // This will make buttons output corresponding "i" values. | |
| 173 for(let i = 0; i < 3; i++) { | |
| 174 buttons[i].onclick = function() { | |
| 175 console.log(i); | |
| 176 }; | |
| 177 } | |
| 178 | |
| 179 var bar = 1; | |
| 180 var bar = 1; // No error thrown. | |
| 181 | |
| 182 let foo = 1; | |
| 183 let foo = 1; // TypeError: Identifier 'foo' has already been declared. | |
| 184 ``` | |
| 185 | |
| 186 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 187 /#sec-let-and-const-declarations) | |
| 188 | |
| 189 **Discussion Notes / Link to Thread:** | |
| 190 | |
| 191 --- | |
| 192 | |
| 193 ## `const` (Block-Scoped Constants) | |
| 194 | |
| 195 Constants (also known as "immutable variables") are variables which cannot be | |
| 196 re-assigned new content. Note that if the value is an object, the object itself | |
| 197 is still mutable. | |
| 198 | |
| 199 `const` has traditionally been supported as a "function scoped" declaration | |
| 200 like `var` (except in Internet Explorer), however in VMs supporting ES6 `const` | |
| 201 is now a block scope declaration. | |
| 202 | |
| 203 **Usage Example:** | |
| 204 | |
| 205 ``` js | |
| 206 const gravity = 9.81; | |
| 207 gravity = 0; // TypeError: Assignment to constant variable. | |
| 208 | |
| 209 gravity === 9.81; // true | |
| 210 ``` | |
| 211 | |
| 212 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 213 /#sec-let-and-const-declarations) | |
| 214 | |
| 215 **Discussion Notes / Link to Thread:** | |
| 216 | |
| 217 --- | |
| 218 | |
| 219 ## `=>` (Arrow Functions) | |
| 220 | |
| 221 Arrow functions provide a concise syntax to create a function, and fix a number | |
| 222 of difficulties with this (e.g. eliminating the need to write `const self = | |
| 223 this`. Particularly useful for nested functions or callbacks. | |
| 224 | |
| 225 Prefer arrow functions over the function keyword, over `f.bind(this)`, and | |
| 226 especially over `goog.bind(f, this)`. | |
| 227 | |
| 228 Arrow functions has an implicit return when used without a body block. | |
| 229 | |
| 230 **Usage Example:** | |
| 231 | |
| 232 ``` js | |
| 233 // General usage, eliminating need for .bind(this). | |
| 234 setTimeout(() => { | |
| 235 this.doSomething(); | |
| 236 }, 1000); // no need for .bind(this) or const self = this. | |
| 237 | |
| 238 // Another example... | |
| 239 window.addEventListener('scroll', (event) => { | |
| 240 this.doSomething(event); | |
| 241 }); // no need for .bind(this) or const self = this. | |
| 242 | |
| 243 // Implicit return: returns the value if expression not inside a body block. | |
| 244 () => 1 // returns 1 | |
| 245 () => {1} // returns undefined - body block does not implicitly return. | |
| 246 () => {return 1;} // returns 1 | |
| 247 ``` | |
| 248 | |
| 249 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 250 /#sec-arrow-function-definitions) | |
| 251 | |
| 252 **Discussion Notes / Link to Thread:** | |
| 253 | |
| 254 --- | |
| 255 | |
| 256 ## Classes | |
| 257 | |
| 258 OOP-style and boilerplate-free class syntax, including inheritance, super(), | |
| 259 static members, and getters and setters. | |
| 260 | |
| 261 **Usage Example:** | |
| 262 | |
| 263 ``` js | |
| 264 class Rectangle extends Shape { | |
| 265 constructor(id, x, y, width, height) { | |
| 266 super(id, x, y); | |
| 267 this.width = width; | |
| 268 this.height = height; | |
| 269 } | |
| 270 static defaultRectangle() { | |
| 271 return new Rectangle('default', 0, 0, 100, 100); | |
| 272 } | |
| 273 move(x, y) { | |
| 274 this.x = x; | |
| 275 this.y = y; | |
| 276 } | |
| 277 }; | |
| 278 ``` | |
| 279 | |
| 280 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 281 /#sec-class-definitions) | |
| 282 | |
| 283 **Discussion Notes / Link to Thread:** | |
| 284 | |
| 285 --- | |
| 286 | |
| 287 ## Block Scope Functions | |
| 288 | |
| 289 **Usage Example:** | |
| 290 | |
| 291 ``` js | |
| 292 { | |
| 293 function foo() { | |
| 294 return 1; | |
| 295 } | |
| 296 // foo() === 1 | |
| 297 { | |
| 298 function foo() { | |
| 299 return 2; | |
| 300 } | |
| 301 // foo() === 2 | |
| 302 } | |
| 303 // foo() === 1 | |
| 304 } | |
| 305 ``` | |
| 306 | |
| 307 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 308 /#sec-functiondeclarationinstantiation) | |
| 309 | |
| 310 **Discussion Notes / Link to Thread:** | |
| 311 | |
| 312 --- | |
| 313 | |
| 314 ## Default Function Parameters | |
| 315 | |
| 316 **Usage Example:** | |
| 317 | |
| 318 ``` js | |
| 319 function f(x, y = 7, z = 42) { | |
| 320 return x + y + z; | |
| 321 } | |
| 322 // f(1) === 50; | |
| 323 ``` | |
| 324 | |
| 325 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 326 /#sec-functiondeclarationinstantiation) | |
| 327 | |
| 328 **Discussion Notes / Link to Thread:** | |
| 329 | |
| 330 --- | |
| 331 | |
| 332 ## Rest Parameters | |
| 333 | |
| 334 Aggregation of function arguments into one Array variable. | |
| 335 | |
| 336 **Usage Example:** | |
| 337 | |
| 338 ``` js | |
| 339 function f(x, y, ...a) { | |
| 340 // for f(1, 2, 3, 4, 5)... | |
| 341 // x = 1, y = 2 | |
| 342 // a = [3, 4, 5] | |
| 343 } | |
| 344 ``` | |
| 345 | |
| 346 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 347 /#sec-function-definitions) | |
| 348 | |
| 349 **Discussion Notes / Link to Thread:** | |
| 350 | |
| 351 --- | |
| 352 | |
| 353 ## Spread Operators | |
| 354 | |
| 355 Spreading the elements from an iterable collection into individual literals as | |
| 356 function parameters. | |
| 357 | |
| 358 **Usage Example:** | |
| 359 | |
| 360 ``` js | |
| 361 // Spreading an Array | |
| 362 var params = [ 'hello', true, 7 ]; | |
| 363 var other = [ 1, 2, ...params ]; // [ 1, 2, 'hello', true, 7 ] | |
| 364 f(1, 2, ...params) === 9; | |
| 365 | |
| 366 // Spreading a String | |
| 367 var str = 'foo'; | |
| 368 var chars = [ ...str ]; // [ 'f', 'o', 'o' ] | |
| 369 ``` | |
| 370 | |
| 371 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 372 /#sec-argument-lists-runtime-semantics-argumentlistevaluation) | |
| 373 | |
| 374 **Discussion Notes / Link to Thread:** | |
| 375 | |
| 376 --- | |
| 377 | |
| 378 ## Object Literal Extensions | |
| 379 | |
| 380 Convenient new ways for object property definition. | |
| 381 | |
| 382 **Usage Example:** | |
| 383 | |
| 384 ``` js | |
| 385 // Computed property name | |
| 386 var x = 'key'; | |
| 387 var obj = {[x]: 1}; | |
| 388 | |
| 389 // Shorthand property | |
| 390 var obj = {x, y}; //equivalent to {x:x, y:y} | |
| 391 | |
| 392 // Method property | |
| 393 var obj = { | |
| 394 foo() {...}, | |
| 395 bar() {...} | |
| 396 } | |
| 397 ``` | |
| 398 | |
| 399 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 400 /#sec-object-initialiser) | |
| 401 | |
| 402 **Discussion Notes / Link to Thread:** | |
| 403 | |
| 404 --- | |
| 405 | |
| 406 ## Template Literals | |
| 407 | |
| 408 Expression interpolation for Strings, with the ability to access raw template | |
| 409 pieces. | |
| 410 | |
| 411 **Usage Example:** | |
| 412 | |
| 413 ``` js | |
| 414 // Simple example | |
| 415 var greeting = 'hello'; | |
| 416 var myName = {first: 'Foo', last: 'Bar'}; | |
| 417 var message = `${greeting}, | |
| 418 my name is ${myName.first + myName.last}`; | |
| 419 // message == 'hello,\nmy name is FooBar' | |
| 420 | |
| 421 // Custom interpolation | |
| 422 function foo (strings, ...values) { | |
| 423 // for foo`bar${42}baz`... | |
| 424 // strings[0] === 'bar'; | |
| 425 // strings[1] === 'baz'; | |
| 426 // values[0] === 42; | |
| 427 | |
| 428 return strings[1] + strings[0] + values[0]; | |
| 429 } | |
| 430 | |
| 431 var newString = foo`bar${42}baz`; // 'bazbar42' | |
| 432 ``` | |
| 433 | |
| 434 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 435 /#sec-template-literals) | |
| 436 | |
| 437 **Discussion Notes / Link to Thread:** | |
| 438 | |
| 439 --- | |
| 440 | |
| 441 ## Binary & Octal Literals | |
| 442 | |
| 443 **Usage Example:** | |
| 444 | |
| 445 ``` js | |
| 446 0b111110111 === 503; | |
| 447 0o767 === 503; | |
| 448 ``` | |
| 449 | |
| 450 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 451 /#sec-literals-numeric-literals) | |
| 452 | |
| 453 **Discussion Notes / Link to Thread:** | |
| 454 | |
| 455 --- | |
| 456 | |
| 457 ## `/u` Unicode Regex Literal | |
| 458 | |
| 459 **Usage Example:** | |
| 460 | |
| 461 ``` js | |
| 462 'ð ®·'.match(/./u)[0].length === 2; | |
| 463 ``` | |
| 464 | |
| 465 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 466 /#sec-get-regexp.prototype.sticky) | |
| 467 | |
| 468 **Discussion Notes / Link to Thread:** | |
| 469 | |
| 470 --- | |
| 471 | |
| 472 ## `\u{}` Unicode String | |
| 473 | |
| 474 **Usage Example:** | |
| 475 | |
| 476 ``` js | |
| 477 '\u{1d306}' == '\ud834\udf06'; // true | |
| 478 ``` | |
| 479 | |
| 480 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 481 /#sec-literals-string-literals) | |
| 482 | |
| 483 **Discussion Notes / Link to Thread:** | |
| 484 | |
| 485 --- | |
| 486 | |
| 487 ## `/y` Regex Sticky Matching | |
| 488 | |
| 489 Keep the matching position sticky between matches and this way support | |
| 490 efficient parsing of arbitrary long input strings, even with an arbitrary | |
| 491 number of distinct regular expressions. | |
| 492 | |
| 493 **Usage Example:** | |
| 494 | |
| 495 ``` js | |
| 496 var re = new RegExp('yy', 'y'); | |
| 497 re.lastIndex = 3; | |
| 498 var result = re.exec('xxxyyxx')[0]; | |
| 499 result === 'yy' && re.lastIndex === 5; // true | |
| 500 ``` | |
| 501 | |
| 502 **Documentation:** [link](http://es6-features.org | |
| 503 /#RegularExpressionStickyMatching) | |
| 504 | |
| 505 **Discussion Notes / Link to Thread:** | |
| 506 | |
| 507 --- | |
| 508 | |
| 509 ## Destructuring Assignment | |
| 510 | |
| 511 Flexible destructuring of collections or parameters. | |
| 512 | |
| 513 **Usage Example:** | |
| 514 | |
| 515 ``` js | |
| 516 // Array | |
| 517 var list = [ 1, 2, 3 ]; | |
| 518 var [ a, , b ] = list; | |
| 519 // a = 1, b = 3 | |
| 520 | |
| 521 // Object | |
| 522 var {width, height, area: a} = rect; | |
| 523 // width = rect.width, height = rect.height, a = rect.area | |
| 524 | |
| 525 // Parameters | |
| 526 function f ([ name, val ]) { | |
| 527 console.log(name, val); | |
| 528 } | |
| 529 function g ({ name: n, val: v }) { | |
| 530 console.log(n, v); | |
| 531 } | |
| 532 function h ({ name, val }) { | |
| 533 console.log(name, val); | |
| 534 } | |
| 535 | |
| 536 f([ 'bar', 42 ]); | |
| 537 g({ name: 'foo', val: 7 }); | |
| 538 h({ name: 'bar', val: 42 }); | |
| 539 | |
| 540 ``` | |
| 541 | |
| 542 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 543 /#sec-destructuring-assignment) | |
| 544 | |
| 545 **Discussion Notes / Link to Thread:** | |
| 546 | |
| 547 --- | |
| 548 | |
| 549 ## Modules | |
| 550 | |
| 551 Support for exporting/importing values from/to modules without global | |
| 552 namespace pollution. | |
| 553 | |
| 554 **Usage Example:** | |
| 555 | |
| 556 ``` js | |
| 557 // lib/rect.js | |
| 558 export function getArea() {...}; | |
| 559 export { width, height, unimportant }; | |
| 560 | |
| 561 // app.js | |
| 562 import {getArea, width, height} from 'lib/rect'; | |
| 563 | |
| 564 ``` | |
| 565 | |
| 566 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 567 /#sec-modules) | |
| 568 | |
| 569 **Discussion Notes / Link to Thread:** | |
| 570 | |
| 571 --- | |
| 572 | |
| 573 ## Symbol Type | |
| 574 | |
| 575 Unique and immutable data type to be used as an identifier for object | |
| 576 properties. | |
| 577 | |
| 578 **Usage Example:** | |
| 579 | |
| 580 ``` js | |
| 581 const foo = Symbol(); | |
| 582 const bar = Symbol(); | |
| 583 typeof foo === 'symbol'; // true | |
| 584 typeof bar === 'symbol'; // true | |
| 585 let obj = {}; | |
| 586 obj[foo] = 'foo'; | |
| 587 obj[bar] = 'bar'; | |
| 588 JSON.stringify(obj); // {} | |
| 589 Object.keys(obj); // [] | |
| 590 Object.getOwnPropertyNames(obj); // [] | |
| 591 Object.getOwnPropertySymbols(obj); // [ foo, bar ] | |
| 592 ``` | |
| 593 | |
| 594 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 595 /#sec-symbol-constructor) | |
| 596 | |
| 597 **Discussion Notes / Link to Thread:** | |
| 598 | |
| 599 --- | |
| 600 | |
| 601 ## `for ...of` Loops | |
| 602 | |
| 603 Convenient operator to iterate over all values of an iterable object. | |
| 604 | |
| 605 **Usage Example:** | |
| 606 | |
| 607 ``` js | |
| 608 // Given an iterable collection `fibonacci`... | |
| 609 for (let n of fibonacci) { | |
| 610 console.log(n); | |
| 611 } | |
| 612 ``` | |
| 613 | |
| 614 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 615 /#sec-for-in-and-for-of-statements) | |
| 616 | |
| 617 **Discussion Notes / Link to Thread:** | |
| 618 | |
| 619 --- | |
| 620 | |
| 621 ## Object Static Methods | |
| 622 | |
| 623 **Usage Example:** | |
| 624 | |
| 625 ``` js | |
| 626 // Object.assign | |
| 627 var o = Object.assign({a:true}, {b:true}, {c:true}); | |
| 628 'a' in o && 'b' in o && 'c' in o; // true | |
| 629 | |
| 630 // Object.setPrototypeOf | |
| 631 Object.setPrototypeOf({}, Array.prototype) instanceof Array; //true | |
| 632 | |
| 633 // Object.is | |
| 634 // Object.getOwnPropertySymbols | |
| 635 ``` | |
| 636 | |
| 637 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 638 /#sec-properties-of-the-object-constructor) | |
| 639 | |
| 640 **Discussion Notes / Link to Thread:** | |
| 641 | |
| 642 --- | |
| 643 | |
| 644 ## String Static & Prototype methods | |
| 645 | |
| 646 **Usage Example:** | |
| 647 | |
| 648 ``` js | |
| 649 // String.raw | |
| 650 // String.fromCodePoint | |
| 651 | |
| 652 // String.prototype.codePointAt | |
| 653 // String.prototype.normalize | |
| 654 // String.prototype.repeat | |
| 655 // String.prototype.startsWith | |
| 656 // String.prototype.endsWith | |
| 657 // String.prototype.includes | |
| 658 ``` | |
| 659 | |
| 660 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 661 /#sec-properties-of-the-string-constructor) | |
| 662 | |
| 663 **Discussion Notes / Link to Thread:** | |
| 664 | |
| 665 --- | |
| 666 | |
| 667 ## Array Static & Prototype Methods | |
| 668 | |
| 669 **Usage Example:** | |
| 670 | |
| 671 ``` js | |
| 672 // Array.from | |
| 673 // Array.of | |
| 674 | |
| 675 // Array.prototype.copyWithin | |
| 676 // Array.prototype.find | |
| 677 // Array.prototype.findIndex | |
| 678 // Array.prototype.fill | |
| 679 // Array.prototype.keys | |
| 680 // Array.prototype.values | |
| 681 // Array.prototype.entries | |
| 682 ``` | |
| 683 | |
| 684 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 685 /#sec-properties-of-the-array-constructor) | |
| 686 | |
| 687 **Discussion Notes / Link to Thread:** | |
| 688 | |
| 689 --- | |
| 690 | |
| 691 ## Number Properties | |
| 692 | |
| 693 **Usage Example:** | |
| 694 | |
| 695 ``` js | |
| 696 // Number.isFinite | |
| 697 // Number.isInteger | |
| 698 // Number.isSafeInteger | |
| 699 // Number.isNaN | |
| 700 // Number.EPSILON | |
| 701 // Number.MIN_SAFE_INTEGER | |
| 702 // Number.MAX_SAFE_INTEGER | |
| 703 ``` | |
| 704 | |
| 705 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 706 /#sec-isfinite-number) | |
| 707 | |
| 708 **Discussion Notes / Link to Thread:** | |
| 709 | |
| 710 --- | |
| 711 | |
| 712 ## Iterators | |
| 713 | |
| 714 **Usage Example:** | |
| 715 | |
| 716 ``` js | |
| 717 let fibonacci = { | |
| 718 [Symbol.iterator]() { | |
| 719 let pre = 0, cur = 1; | |
| 720 return { | |
| 721 next () { | |
| 722 [ pre, cur ] = [ cur, pre + cur ]; | |
| 723 return { done: false, value: cur }; | |
| 724 } | |
| 725 }; | |
| 726 } | |
| 727 }; | |
| 728 ``` | |
| 729 | |
| 730 **Documentation:** [link]() | |
| 731 | |
| 732 **Discussion Notes / Link to Thread:** | |
| 733 | |
| 734 --- | |
| 735 | |
| 736 ## Generators | |
| 737 | |
| 738 Special iterators with specified pausing points. | |
| 739 | |
| 740 **Usage Example:** | |
| 741 | |
| 742 ``` js | |
| 743 function* range(start, end, step) { | |
| 744 while (start < end) { | |
| 745 yield start; | |
| 746 start += step; | |
| 747 } | |
| 748 } | |
| 749 | |
| 750 for (let i of range(0, 10, 2)) { | |
| 751 console.log(i); // 0, 2, 4, 6, 8 | |
| 752 } | |
| 753 | |
| 754 ``` | |
| 755 | |
| 756 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 757 /#sec-generator-function-definitions) | |
| 758 | |
| 759 **Discussion Notes / Link to Thread:** | |
| 760 | |
| 761 --- | |
| 762 | |
| 763 ## `Map` | |
| 764 | |
| 765 **Usage Example:** | |
| 766 | |
| 767 ``` js | |
| 768 var key = {}; | |
| 769 var map = new Map(); | |
| 770 | |
| 771 map.set(key, 123); | |
| 772 | |
| 773 map.has(key) && map.get(key) === 123; // true | |
| 774 ``` | |
| 775 | |
| 776 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 777 /#sec-map-objects) | |
| 778 | |
| 779 **Discussion Notes / Link to Thread:** | |
| 780 | |
| 781 --- | |
| 782 | |
| 783 ## `Set` | |
| 784 | |
| 785 **Usage Example:** | |
| 786 | |
| 787 ``` js | |
| 788 var obj = {}; | |
| 789 var set = new Set(); | |
| 790 | |
| 791 set.add(123); | |
| 792 set.add(123); | |
| 793 | |
| 794 set.has(123); // true | |
| 795 ``` | |
| 796 | |
| 797 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 798 /#sec-set-objects) | |
| 799 | |
| 800 **Discussion Notes / Link to Thread:** | |
| 801 | |
| 802 --- | |
| 803 | |
| 804 ## `WeakMap` | |
| 805 | |
| 806 WeakMap does not prevent garbage collection if nothing else refers to an object | |
| 807 within the collection. | |
| 808 | |
| 809 **Usage Example:** | |
| 810 | |
| 811 ``` js | |
| 812 var key = {}; | |
| 813 var weakmap = new WeakMap(); | |
| 814 | |
| 815 weakmap.set(key, 123); | |
| 816 | |
| 817 weakmap.has(key) && weakmap.get(key) === 123; // true | |
| 818 ``` | |
| 819 | |
| 820 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 821 /#sec-weakmap-objects) | |
| 822 | |
| 823 **Discussion Notes / Link to Thread:** | |
| 824 | |
| 825 --- | |
| 826 | |
| 827 ## `WeakSet` | |
| 828 | |
| 829 WeakSet does not prevent garbage collection if nothing else refers to an object | |
| 830 within the collection. | |
| 831 | |
| 832 **Usage Example:** | |
| 833 | |
| 834 ``` js | |
| 835 var obj1 = {}; | |
| 836 var weakset = new WeakSet(); | |
| 837 | |
| 838 weakset.add(obj1); | |
| 839 weakset.add(obj1); | |
| 840 | |
| 841 weakset.has(obj1); // true | |
| 842 ``` | |
| 843 | |
| 844 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 845 /#sec-weakset-objects) | |
| 846 | |
| 847 **Discussion Notes / Link to Thread:** | |
| 848 | |
| 849 --- | |
| 850 | |
| 851 ## Typed Arrays | |
| 852 | |
| 853 A lot of new typed Arrays... | |
| 854 | |
| 855 **Usage Example:** | |
| 856 | |
| 857 ``` js | |
| 858 new Int8Array(); | |
| 859 new UInt8Array(); | |
| 860 new UInt8ClampedArray() | |
| 861 // ...You get the idea. Click on the Documentation link below to see all. | |
| 862 ``` | |
| 863 | |
| 864 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 865 /#sec-typedarray-objects) | |
| 866 | |
| 867 **Discussion Notes / Link to Thread:** | |
| 868 | |
| 869 --- | |
| 870 | |
| 871 ## `Proxy` | |
| 872 | |
| 873 Hooking into runtime-level object meta-operations. | |
| 874 | |
| 875 **Usage Example:** | |
| 876 | |
| 877 ``` js | |
| 878 let target = { | |
| 879 foo: 'Welcome, foo' | |
| 880 }; | |
| 881 let proxy = new Proxy(target, { | |
| 882 get (receiver, name) { | |
| 883 return name in receiver ? receiver[name] : `Hello, ${name}`; | |
| 884 } | |
| 885 }); | |
| 886 proxy.foo === 'Welcome, foo'; // true | |
| 887 proxy.world === 'Hello, world'; // true | |
| 888 ``` | |
| 889 | |
| 890 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 891 /#sec-proxy-object-internal-methods-and-internal-slots) | |
| 892 | |
| 893 **Discussion Notes / Link to Thread:** | |
| 894 | |
| 895 --- | |
| 896 | |
| 897 ## `Reflection` | |
| 898 | |
| 899 Make calls corresponding to the object meta-operations. | |
| 900 | |
| 901 **Usage Example:** | |
| 902 | |
| 903 ``` js | |
| 904 let obj = { a: 1 }; | |
| 905 Object.defineProperty(obj, 'b', { value: 2 }); | |
| 906 obj[Symbol('c')] = 3; | |
| 907 Reflect.ownKeys(obj); // ['a', 'b', Symbol(c)] | |
| 908 ``` | |
| 909 | |
| 910 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 911 /#sec-reflection) | |
| 912 | |
| 913 **Discussion Notes / Link to Thread:** | |
| 914 | |
| 915 --- | |
| 916 | |
| 917 ## Math Methods | |
| 918 | |
| 919 A lot of new Math methods. | |
| 920 | |
| 921 **Usage Example:** | |
| 922 | |
| 923 ``` js | |
| 924 // See Doc | |
| 925 ``` | |
| 926 | |
| 927 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0 | |
| 928 /#sec-math) | |
| 929 | |
| 930 **Discussion Notes / Link to Thread:** | |
| 931 | |
| 932 --- | |
| OLD | NEW |