Redux
- Обновление без сохранения исходной позиции в массиве (индекса)
return {
...state.items,
{
...item,
count: item.count++Redux
return {
...state.items,
{
...item,
count: item.count++| compute_sum: if (matrix) { | |
| for(var x = 0; x < matrix.length; x++) { | |
| var row = matrix[x]; | |
| if (!row) break compute_sum; | |
| for(var y = 0; y < row.length; y++) { | |
| var cell = row[y]; | |
| if (isNaN(cell)) break compute_sum; | |
| sum += cell; | |
| } | |
| } |
| function createCounter(counter = 0) { | |
| return function() { | |
| return console.log(counter++); | |
| } | |
| } | |
| var tic = createCounter(9); | |
| // console.log(counter); // будет не доступна из вне | |
| tic(); | |
| tic(); |
| Всплытие переменных | |
| ------------------------------------- | |
| var x = 'внешняя'; | |
| function inner(){ | |
| console.log(x); | |
| var x = 'inner'; | |
| } | |
| inner(); // undefined | |
| ---- |
| (function (name) { | |
| console.log(`Приветствую, ${name}!`); | |
| })('Иван'); // Приветствую, Иван! |
| GET | |
| POST | |
| PUT | |
| DELETE | |
| ЗДЕСЬ! | |
| https://uncaughtexception.ru/2017/05/15/kak-razrabotat-praktichnyy-rest-api.html | |
| https://habrahabr.ru/post/144011/ |
| const [,, first, second] = array; | |
| const [one, ...rest] = array; // разделит массив на остатки | |
| const { name, age } = me; | |
| const { name: firstName, age } = me; | |
| const me = { | |
| age: 26, | |
| gender: "male", | |
| city: "nsk" | |
| }; |
| class Point{ | |
| constructor(x, y) { | |
| this.x = x; | |
| this.y = y; | |
| } | |
| toString() { | |
| return `(${this.x}, ${this.y})`; | |
| } | |
| } |
| // Get, Set через деструктуризацию | |
| class User { | |
| constructor(firstName, lastName) { | |
| this.firstName = firstName; | |
| this.lastName = lastName; | |
| } | |
| get fullName() { | |
| return `${this.firstName} ${this.lastName}`; |
| const arr = [1,2,3]; | |
| arr.map((i, item) => { | |
| console.log(item) | |
| }); | |
| arr.forEach((item, i) => console.log(item, i)) | |
| for (let item of arr) { | |
| console.log(item); |