- Krótka historia JavaScript'u (ECMA Script'u)
- TC39 Process
- Wsparcie przeglądarek
- Chrome DevTools (zajawka)
- Istotne / interesujące / nowe 'ficzery' JS
Brendan Eich JavaScript jako część Netscape Navigator
Coś jak Scheme ale ze składnią podobną do Javy.
Netscape przekazuje JS do ECMA International
TC 39 (Technical Committee 39)
Powstaje standard ECMAScript (ECMA-262)
ECMAScript 3
ECMAScript 5
ECMAScript 6 == ES6 == ES2015 Bardzo dużo nowych feature'ów
Rozpoczął się proces stopniowej ewolucji języka
ECMAScript proposals GitHub Repo
- Stage 0 - Strawman
- Stage 1 - Proposal
- Stage 2 - Draft
- Stage 3 - Candidate
- Stage 4 - Finished
Co roku nowy release zawierający jakąś część stage 4: ECMAScript 2016, ECMAScript 2017, ECMAScript...
Stage 1 - 3 == ES.Next
- Chrome - V8
- Firefox - SpiderMonkey
- Safari - JavaScriptCore
- Edge - Chakra
Bardzo zróżnicowany poziom pokrycia feature'ów.
Transpiluje feature'y z aktualnego standardu do ES5. ES2015-2017 --> ES5
Dodatkowo można ustawić docelowe środowisko, co wyłącza transformację feature'ów tam dostępnych.
preset-stage-3 preset-stage-2 == stage-2 i 3
Filmik, o którym wspomniałem na zajęciach
Podstawa rozumnego programowania w JS.
równie istotne MDN - dziedziczenie... FunFun Function - playlista
- default function parameters
- rest parameters
- spread operator
- destructing declarations / assignment / parameters
- rest / spread properties
- object literal (getters, setters / computed properties / shorthand properties / shorthand methods)
- template literals
- const / let
- arrow function
- class
- new Built-ins: Map, Set, Promise, ...
- async / await
function func(a, b = 'default') {
console.log(a, b);
}
func(1);
// 1 'default'function func(a, ...args){
console.log(a, args);
}
func(1, 2, 3);
// 1 [2,3]const arr1 = [1, 2, 3];
const arr2 = [4, 5, 6];
const arr3 = [...arr1, ...arr2];
console.log(arr3);
// [1,2,3,4,5,6]const [a, b, c] = [1,2,3];
//---
const {a, b} = {a: 1, b: 2, c: 3};
const {a: foo, b: foo2} = {a: 1, b: 2, c: 3};
//---
[a, b] = [1, 2]
({a, b} = {a: 1, b: 2});
//---
function func({a, b = 'default'}){
console.log(a,b);
}
func({a: 1}); // 1 defaultconst obj1 = {a: 1};
const obj2 = {b: 2, c: 3};
const obj3 = {...obj1, ...obj2};
const {a, ...other} = obj3;const computedName = computeTheName();
const propShorthand = 'bar';
const obj = {
[computedName]: 'foo',
propShorthand,
methodShorthand(){
return 'hello';
}
};const obj = {
arr: ['v1', 'v2'],
get latest() {
if (this.arr.length === 0) return undefined;
return this.arr[this.arr.length - 1];
},
set latest(v) {
if (this.arr.length === 0) this.arr.push(v);
this.arr[this.arr.length - 1] = v;
},
};const val = 'hello';
const myObject = {
toString() {
return 'value of myObject.toString()';
},
};
const foo = `${val}. obj: ${myObject}`;
console.log(foo);
// hello. obj: value of myObject.toString()const,let- block scope- var - function scope
uwaga:
const someObj = {a: 'original'};
someObj = foo; // Syntax Error!
// but
someObj.a = 'modified';
console.log(someObj);
// {a: 'modified'}const counter= {
cnt: 0,
observe(el){
el.addEventListener('click', () => {
// this === counter
this.cnt++;
});
}
};
const pow2 = (a) => a * a;
//---
const pow2 = (a) => {
return a * a;
}
// returning an object
const func = () => ({a: 1});class Base {
constructor(a) {
this.a = a;
}
}
class Foo extends Base {
constructor(a, b) {
super(a);
this.b = b;
}
foo() {
return `a: ${this.a} b: ${this.b}`;
}
}
const instance = new Foo('foo', 'bar');
console.log(instance.foo());
// a: foo b: barMDN - Map MDN - Set MDN - Promise ...
const promise = new Promise((resolve, reject)=>{
setTimeout(()=>{
const rand = Math.random();
if(Math.round(rand) === 1){
resolve(rand);
} else {
reject(rand);
}
}, 1000);
});
promise
.then(result => console.log(`ok ${result}`))
.catch(reason => consol.log(`bad ${reason}`));async function fetchJSON(url){
const response = await fetch(url);
const responseJson = await response.json();
return responseJson;
}
fetchJSON('<<url_to_the_json>>')
.then(result => {/*...*/})http://2ality.com/2015/11/tc39-process.html
https://www.html5rocks.com/en/tutorials/internals/howbrowserswork/#Layout

