This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// custom | |
const compose = (...functions) => data => | |
functions.reduceRight((value, func) => func(value), data) | |
const pipe = (...functions) => data => | |
functions.reduce((value, func) => func(value), data) | |
// with ramda | |
import r from 'ramda'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { | |
View, | |
Text, | |
FlatList, | |
StyleSheet | |
} from 'react-native'; | |
import { ListItem } from 'react-native-elements'; | |
class Users extends React.Component { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const names = [{name: 'Arsen'}, {name: 'Vazgen'}, {name: 'Vlad'}]; | |
const User = ({ name, ...rest }) => { | |
return ( | |
<div> | |
<span> | |
{ name } | |
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const delay = ms => new Promise(res => setTimeount(res, ms)); | |
async function * gen() { | |
await delay(1000); | |
yield 1; | |
await delay(1000); | |
yield 2; | |
await delay(1000); | |
yield 3; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ля получения значений подобно циклу for...of, можно использовать метод | |
let arr = [ 3, 5, 7 ]; | |
arr.foo = "hello"; | |
arr.forEach(function (element, index) { | |
console.log(element); // выведет "3", "5", "7" | |
console.log(index); // выведет "0", "1", "2" | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
To learn this, you first have to learn what this is not, despite any assumptions or misconceptions that | |
may lead you down those paths. this is neither a reference to the function itself, nor is it a reference | |
to the function's lexical scope. | |
this is actually a binding that is made when a function is invoked, and what it references is determined | |
entirely by the call-site where the function is called. | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reslut = someFunc(); // запись результат выполнения someFunc в переменную result | |
const funcLink = somfFunc; // запись ссылки на функцию в переменную funcLink | |
// * * * * * Default example * * * * * | |
this.age = 20; | |
const module = { | |
age: 12, | |
showAge: function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO - подумать, каким образом выполнить все это в функциональном стиле | |
// * * * * * Заполнение массива * * * * * | |
// Заполнить массив нулями и единицами, при этом данные значения | |
// чередуются, начиная с нуля. | |
function foo2() { | |
const len = 10; | |
let arr = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myArr = [1, 2, 3, 4, 5, 6]; | |
// map создает новый массив на основании вызова callback для каждого элемента (трансформация) | |
const newMap = myArr.map(i => { | |
return i * 2; | |
}); | |
// forEach выполняет callback для каждого элемента массива (перебор) | |
const newForEach = myArr.forEach(i => { | |
return i * 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function customMap(arr, callback, thisArgs) { | |
let newArr = []; | |
for (let i = 0; i < arr.length; i++) { | |
newArr.push(callback.call(thisArgs, arr[i])); | |
} | |
return newArr; | |
} |
NewerOlder