Ua hoʻomalu ʻo JavaScript i ka pūnaewele a me ECMAScript, ke ulu nei ke kumu o ka ʻōlelo. ʻO ka wehewehe hou (ES6 a i ʻole JS2), i manaʻo ʻia i ka waena o kēia makahiki, e lawe mai i nā mea hou he nui i hiki ke hoʻāʻo i kēia lā. I kēia manawa ke kākoʻo ʻoi loa ʻo Firefox, akā hiki i nā polyfills ma o nā transpilers i kapa ʻia e like me Google Traceur ke hiki pū kekahi. ʻO ka mea aʻe kahi hōʻike pōkole o nā hiʻohiʻona hou o ES6.
Ke hou koho hua'ōlelo mai la i ka hailona maikai ma mua o var: Scoping manawa hoi e like me ia ma nā 'ōlelo' ē (C / C ++, Iawa), i mea no ke aha la ina-ālai 'manawa no hoi i ko lakou mau laulā. ʻO ke kau ʻana, ʻo ia hoʻi ka lawe ʻana mai i mua o nā ʻōlelo loli (ʻaʻole nā kuleana waiwai) i loko o kēlā me kēia āpau:
console.log(x); var x = 'foo'; // undefined console.log(y); let y = 'bar'; // not initialized
Lōʻihi ka helu o nā hana hou ʻē aʻe: nā paʻa (const), nā helu paʻamau no nā hana (function pow (a, b = 2) {hoʻihoʻi i ka Math.pow (a, b);}), kahi nota hou no nā hana (let pow = (a, b = 2) => Math.pow (a, b);), kahi lehulehu o nā hana hou (hana hou (), loaʻa (), hoʻomakaWith (), loaʻa (), findIndex ()), ke kūkulu loop hou no ... o.
ʻO nā ʻano ʻikepili hou i hoʻonohonoho ʻia, palapala ʻāina, hope a me nā hōʻailona, ka lawe ʻia ʻana o (nā ʻāpana o nā ʻē aʻe) nā faila JavaScript me ka lawe mai a me kahi syntax intuitive hou no nā papa a me nā hoʻoilina e pono e haʻi pū ʻia. ʻO ka manawa pinepine kekahi mau mea liʻiliʻi akā kali ʻia e like me ka hiki o ka haʻihaʻi o ka laina i nā lita kaula (e nānā i nā kaha ʻōlelo kūikawā):
`foo bar`
Ua ʻoi aku ka lōʻihi o JavaScript ma mua o kahi pono hana no ka hoʻopunipuni pūnaewele liʻiliʻi - hana ia i nā polokalamu pūnaewele ʻoi loa a kiʻekiʻe ʻole i lalo o kā lākou mau ʻoneki. Me ka nui o nā hana kōkua hou a me ke kākoʻo i loaʻa mai iā ES6, ʻelua manawa leʻaleʻa ka hoʻolālā ʻana.
ʻO wai ka mea i makemake ʻole e nānā i ke kaulike o nā helu ʻelua me ke kōkua o ka helu mau hou. EPSILON , nona ka waiwai ma waena o 1 a me ka helu lana lana kiʻekiʻe aʻe?
let cmp = (a,b) => Math.abs(a-b)