|
1 |
| -# ES6 on io.js |
| 1 | +# ES6 i io.js |
2 | 2 |
|
3 |
| -io.js is built against modern versions of [V8](https://code.google.com/p/v8/). By keeping up-to-date with the latest releases of this engine we ensure new features from the [JavaScript ECMA-262 specification](http://www.ecma-international.org/publications/standards/Ecma-262.htm) are brought to io.js developers in a timely manner, as well as continued performance and stability improvements. |
| 3 | +io.js benytter en moderne versjon av [V8](https://code.google.com/p/v8/). Ved |
| 4 | +å holde prosjektet oppdatert med de siste versjonene av V8 sørger vi for at nye |
| 5 | +funksjoner fra [JavaScript ECMA-262 |
| 6 | +spesifikasjonen](http://www.ecma-international.org/publications/standards/Ecma-262.htm) |
| 7 | +er tilgjengelig for io.js utviklere innen rimelig tid. I tillegg vil |
| 8 | +sikkerhets- og ytelesesforbedringer komme raskt. |
4 | 9 |
|
5 |
| -Version {{project.current_version}} of io.js ships with V8 {{project.current_v8}}, which includes ES6 features well beyond version 3.26.33 that will be shipped with joyent/ [email protected]. |
| 10 | +Versjon {{project.current_version}} av io.js kommer med V8 versjon {{project.current_v8}}, denne inkluderer |
| 11 | +ES6-funksjoner godt forbi versjon 3.28.73 som vil bli levert med Node.js™ |
| 12 | +0.12.x. |
6 | 13 |
|
7 |
| -## No more --harmony flag |
| 14 | +## Slutt på --harmony-flagget |
8 | 15 |
|
9 |
| -On joyent/ [email protected] (V8 3.26), the `--harmony` runtime flag enabled all **completed **, **staged ** and **in progress ** ES6 features together, in bulk (with the exception of nonstandard/non-harmonious semantics for `typeof` which were hidden under `--harmony-typeof`). This meant that some really buggy or even broken features like [proxies ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) were just as readily available for developers as [generators ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*), which had very little or even no known-issues. As such, it was best practice to either enable only certain features by using specific runtime harmony feature flags (e.g. `--harmony-generators`), or simply enable all of them and then use a restricted subset. |
| 16 | +Med Node.js™@0.12.x (V8 3.28+) aktiverte `--harmony`-flagget ES6-funksjonene |
| 17 | +**completed**, **staged** og **in progress** (med unntak av `proxies` som ble |
| 18 | +skjult ved bruk av `--harmony-proxies`). Dette resulterte i at ustabile, eller |
| 19 | +til og med ødelagte, funksjoner som [Arrow |
| 20 | +Functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) |
| 21 | +var like tilgjengelig for utviklere som |
| 22 | +[generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*), |
| 23 | +som hadde veldig få, eller ingen, kjente problemer. Følgelig var det sikrest å |
| 24 | +aktivere enten et fåtall funksjoner ved å bruke spesifikke harmony-flagg |
| 25 | +(f.eks. `--harmony-generators`), eller aktivere dem alle og deretter bare |
| 26 | +bruke en begrenset delmengde. |
10 | 27 |
|
11 |
| -With [email protected] (V8 4.1+), all that complexity goes away. All harmony features are now logically split into three groups for **shipping **, **staged ** and **in progress ** features: |
| 28 | +Med [email protected] (V8 4.1+) forsvinner all denne kompleksiteten. Alle harmony-funksjoner |
| 29 | +er nå logisk fordelt inn i tre grupper for **shipping**-, **staged**- og **in |
| 30 | +progress**-funksjoner: |
12 | 31 |
|
13 |
| -* All **shipping** features, the ones that V8 has considered stable, like [generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*), [templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings), [new string methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla#Additions_to_the_String_object) and many others are turned **on by default on io.js** and do **NOT** require any kind of runtime flag. |
14 |
| -* Then there are **staged** features which are almost-completed features that haven't been completely tested or updated to the latest spec yet and therefore are not considered stable by the V8 team (e.g. there might be some edge cases left to discover). This is probably the equivalent of the state of [generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) on 3.26. These are the "use at your own risk" type of features that now require a runtime flag: `--es_staging` (or its synonym, `--harmony`). |
15 |
| -* Finally, all **in progress** features can be activated individually by their respective harmony flag (e.g. `--harmony_arrow_functions`), although this is highly discouraged unless for testing purposes. |
| 32 | + * Alle **shipping**-funksjoner, som V8 har vurdert som stabile, for eksempel |
| 33 | +[generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*), |
| 34 | +[templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings), |
| 35 | +[new string methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla#Additions_to_the_String_object) |
| 36 | +og mange flere er nå skrudd **på som standard i io.js** og krever **INGEN** |
| 37 | +flagg. |
16 | 38 |
|
17 |
| -## Which ES6 features ship with io.js by default (no runtime flag required)? |
| 39 | + * Deretter er det **staged**-funksjoner, som er nesten fullførte funksjoner |
| 40 | +som ikke har blitt fullstendig testet eller oppdatert i henhold til den siste |
| 41 | +spesifikasjonen enda. Følgelig er de ikke ansett som stabile av V8 laget |
| 42 | +(f.eks. kan det være noen 'edge cases' som ikke har blitt oppdaget). Dette er |
| 43 | +mest sannsynlig ekvivalent med tilstanden til |
| 44 | +[generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) |
| 45 | +i 3.26. Disse er "bruk på egen risiko" funksjoner som nå krever flagget : |
| 46 | +`--es_staging` (eller synonymet, `--harmony`). |
18 | 47 |
|
| 48 | + * Til slutt, alle **in progress**-funksjoner kan bli aktivert individuelt av |
| 49 | +deres respektive harmony-flagg (f.eks. `--harmony_arrow_functions`), selv om |
| 50 | +dette ikke er anbefalt med mindre det brukes til testing. |
19 | 51 |
|
20 |
| -* Block scoping |
| 52 | +## Hvilke ES6-funksjoner følger med io.js som standard (uten å bruke flagg)? |
21 | 53 |
|
22 |
| - * [let](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let) |
| 54 | + * Block scoping |
23 | 55 |
|
24 |
| - * [const](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const) |
| 56 | + * [let](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let) |
25 | 57 |
|
26 |
| - * `function`-in-blocks |
| 58 | + * [const](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const) |
27 | 59 |
|
28 |
| - >As of v8 3.31.74.1, block-scoped declarations are [intentionally implemented with a non-compliant limitation to strict mode code](https://groups.google.com/forum/#!topic/v8-users/3UXNCkAU8Es). Developers should be aware that this will change as v8 continues towards ES6 specification compliance. |
| 60 | + * `function`-in-blocks |
29 | 61 |
|
30 |
| -* Collections |
| 62 | +> Fra og med v8 3.31.74.1, er block-scoped declarations [forsettlig implementert |
| 63 | +> med en ikke-kompatibel begrensning til strict modus |
| 64 | +> kode](https://groups.google.com/forum/#!topic/v8-users/3UXNCkAU8Es). |
| 65 | +> Utviklere bør være klar over at dette vil endres i takt med V8 sin |
| 66 | +> implementasjon av ES6-spesifikasjonen. |
31 | 67 |
|
32 |
| - * [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) |
| 68 | + * Collections |
33 | 69 |
|
34 |
| - * [WeakMap](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) |
| 70 | + * [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) |
35 | 71 |
|
36 |
| - * [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) |
| 72 | + * [WeakMap](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) |
37 | 73 |
|
38 |
| - * [WeakSet](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) |
| 74 | + * [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) |
39 | 75 |
|
40 |
| -* [Generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) |
| 76 | + * [WeakSet](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) |
41 | 77 |
|
42 |
| -* [Binary and Octal literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Numeric_literals) |
| 78 | + * [Generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) |
43 | 79 |
|
44 |
| -* [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) |
| 80 | + * [Binary and Octal literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Numeric_literals) |
45 | 81 |
|
46 |
| -* [New String methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla#Additions_to_the_String_object) |
| 82 | + * [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) |
47 | 83 |
|
48 |
| -* [Symbols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) |
| 84 | + * [New String methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla#Additions_to_the_String_object) |
49 | 85 |
|
50 |
| -* [Template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings) |
| 86 | + * [Symbols](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) |
51 | 87 |
|
52 |
| -You can view a more detailed list, including a comparison with other engines, on the [compat-table](https://kangax.github.io/compat-table/es6/) project page. |
| 88 | + * [Template strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings) |
53 | 89 |
|
54 |
| -## Which ES6 features are behind the --es_staging flag? |
| 90 | +Du kan se en mer detaljert liste med sammenligninger opp mot andre motorer på |
| 91 | +prosjektsiden til (https://kangax.github.io/compat-table/es6/)[compat-table]. |
55 | 92 |
|
56 |
| -* [Classes](https://github.com/lukehoban/es6features#classes) (strict mode only) |
57 |
| -* [Object literal extensions](https://github.com/lukehoban/es6features#enhanced-object-literals) |
| 93 | +## Hvilke ES6-funksjoner ligger i --es_staging-flagget? |
58 | 94 |
|
59 |
| -* [`Symbol.toStringTag`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) (user-definable results for `Object.prototype.toString`) |
| 95 | + * [Classes](https://github.com/lukehoban/es6features#classes) (strict mode only) |
60 | 96 |
|
61 |
| -## I have my infrastructure set up to leverage the --harmony flag. Should I remove it? |
| 97 | + * [Object literal extensions(https://github.com/lukehoban/es6features#enhanced-object-literals)] |
62 | 98 |
|
63 |
| -The current behaviour of the `--harmony` flag on io.js is to enable **staged** features only. After all, it is now a synonym of `--es_staging`. As mentioned above, these are completed features that have not been considered stable yet. If you want to play safe, especially on production environments, consider removing this runtime flag until it ships by default on V8 and, consequently, on io.js. If you keep this enabled, you should be prepared for further io.js upgrades to break your code if V8 changes their semantics to more closely follow the standard. |
| 99 | + * [`Symbol.toStringTag`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) (user-definable results for `Object.prototype.toString`) |
64 | 100 |
|
65 |
| -## How do I find which version of V8 ships with a particular version of io.js? |
| 101 | +## Which ES6 features are in progress? |
66 | 102 |
|
67 |
| -io.js provides a simple way to list all dependencies and respective versions that ship with a specific binary through the `process` global object. In case of the V8 engine, type the following in your terminal to retrieve its version: |
| 103 | +New features are constantly being added to the V8 engine. Generally speaking, expect them to land on a future io.js release, although timing is unknown. |
| 104 | + |
| 105 | +You may list all the *in progress* features available on each io.js release by grepping through the `--v8-options` argument. Please note that these are incomplete and possibly broken features of V8, so use them at your own risk: |
| 106 | + |
| 107 | +```sh |
| 108 | +iojs --v8-options | grep "in progress" |
| 109 | +``` |
| 110 | + |
| 111 | +## Jeg bruker --harmony-flagg i produksjon. Burde jeg fjerne det? |
| 112 | + |
| 113 | +Den nåværende oppførselen til `--harmony`-flagget i io.js er å kun aktivere |
| 114 | +**staged**-funksjoner. Dette er tross alt nå synonymt med `--es_staging`. Som |
| 115 | +nevnt ovenfor er dette fullførte funksjoner som enda ikke er ansett som stabile |
| 116 | +enda. Hvis du ønsker å være på den sikre siden, kanskje spesielt med tanke på |
| 117 | +produksjonsmiljøer, bør du vurdere å fjerne dette flagget inntil det leveres |
| 118 | +som standard av V8 og io.js. Hvis du fortsetter å ha flagget aktivert bør du |
| 119 | +være forberedt på at nyere io.js-oppgraderinger kan ødelegge koden din dersom |
| 120 | +V8 endrer semantikken sin til å være mer lik standarden. |
| 121 | + |
| 122 | +## Hvordan finner jeg ut hvilken versjon av V8 en gitt io.js versjon har? |
| 123 | + |
| 124 | +io.js har en enkel måte å liste alle avhengigheter/dependencies og versjoner av |
| 125 | +en gitt binær med det globale objektet `process`. For å finne-V8 versjonen kan |
| 126 | +du skrive følgende i terminalen: |
68 | 127 |
|
69 | 128 | ```sh
|
70 | 129 | iojs -p process.versions.v8
|
|
0 commit comments