diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 13771fc..e089bc2 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -6,6 +6,8 @@ - [Web](./dev/web/main.md) - [front](./dev/web/front/main.md) - [babel and babel-preset-stage-2](./dev/web/front/babel-preset-stage-2.md) + - [js](./dev/web/javascript/.md) + - [ES6 features](./dev/web/javascript/es6.md) - [Tools](./dev/tools/main.md) - [Git](./dev/tools/git.md) - [SVN](./dev/tools/svn.md) diff --git a/src/dev/web/javascript/.md b/src/dev/web/javascript/.md new file mode 100644 index 0000000..d7d07d1 --- /dev/null +++ b/src/dev/web/javascript/.md @@ -0,0 +1 @@ +# js diff --git a/src/dev/web/javascript/es6.md b/src/dev/web/javascript/es6.md new file mode 100644 index 0000000..9848656 --- /dev/null +++ b/src/dev/web/javascript/es6.md @@ -0,0 +1,85 @@ +# Presentation of the main ES6 features + +## Spread Operator + +It allows an iterable to expand items in it. + +```javascript +array = [1, 2]; +appended = [3,4]; + +all = [...aray, ...appended] +console.log(all) +``` + +This can be usefull in some situations like this one : + +```javascript +array = [1, 2, 3, 4]; +console.log(Math.min(...array)); +``` + +istead of the old syntax + +```javascript +array = [1, 2, 3, 4]; +console.log(Math.min.apply(null, array)); +``` + +## Rest Operator + +Represent infinite number or args in an array + +```javascript +const sum = (...numbers) => { + return numbers.reduce((previous, current) => { + return previous + current; + }); +}; +``` + +## Arrow Function + +Function can now be written like this + +```javascript +const f = (a, b) => a + b; +console.log(f(1,2)); +``` + +instead of + +```javascript +function f(a, b) { + return a + b; +} +console.log(f(1,2)); +``` + +## Default parameters + +With arrow syntax ! + +```javascript +const f = (a = 10) => console.log(a); +f(); +f(1); +``` + +## Destructuring (arrays and objects) + +With arrays + +```javascript +const array = [1, 2]; +const [a, b] = array; +console.log(a, b) +``` + +or objects + +```javascript +const person = { name: "Jesus", age: "33" }; +const { name, age } = person; +console.log(name, age); +``` diff --git a/src/dev/web/javascript/main.md b/src/dev/web/javascript/main.md new file mode 100644 index 0000000..6c02582 --- /dev/null +++ b/src/dev/web/javascript/main.md @@ -0,0 +1 @@ +# All js stuff goes here