This file contains hidden or 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
| let quickSort = (arr) => { | |
| let low = 0; | |
| let high = arr.length; | |
| if (high < 2) return arr; | |
| let pivotIndex = Math.trunc(high / 2); | |
| let pivot = arr[pivotIndex]; | |
| let lessArr = []; | |
| let highArr = []; | |
| for (let i = 0; i < high; i++) { | |
| if (i === pivotIndex) { |
This file contains hidden or 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 getRandomNumber = (from, to) => { | |
| const randomNumber = Math.random(); | |
| const readyRandomNumber = Math.floor(randomNumber * to) + from; | |
| return readyRandomNumber; | |
| }; |
This file contains hidden or 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
| export default function httpRequest(method, url, body = undefined, accessToken = localStorage?.getItem("accessToken")) { | |
| const controller = new AbortController(); | |
| const signal = controller.signal; | |
| const request = fetch(SERVER_PATH + url, { | |
| method: method, | |
| mode: "cors", | |
| headers: { | |
| "Content-Type": "application/json", | |
| authorization: `Bearer ${accessToken}` |
This file contains hidden or 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
| //создание переменных происходит при помощи $ | |
| $mainColor: red; | |
| $secondColor: blue; | |
| .container{ | |
| background-color: $mainColor; | |
| color: $secondColor; | |
| .btn{ | |
| color: $mainColor; |
This file contains hidden or 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
| . - любой символ | |
| [] - тут можно указывать любые символы, а так же диапазоны через - пример [1-8] | |
| $ - конец строки | |
| ^ - начало строки | |
| \n - перенос строки | |
| \ - экранирование | |
| \d - любая цифра | |
| \D - любой символ кроме цифры | |
| \s - пробелы | |
| \S - все символы кроме пробела |
This file contains hidden or 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 items = [ | |
| {name: 'Bike', price: 100}, | |
| {name: 'Tv', price: 200}, | |
| {name: 'Aalbum', price: 10}, | |
| {name: 'Book', price: 5}, | |
| {name: 'Phone', price: 1000}, | |
| {name: 'Keyboard', price: 25}, | |
| ] | |
| //возвращает новый массив из отфильтрованных жлементов |
This file contains hidden or 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
| /*Для контейнера*/ | |
| display:grid; // делаем наш элемент гридом. | |
| /*ВСЕ РАВНО ДЛЯ АДАПТИВНОГО ДИЗАЙНА ПРИДЕТЬСЯ ИСПЛЬЗОВАТЬ @media*/ | |
| /*Либо используем статические значения размеров колонок, либо auto-fit/auto-fill вместе с minmax где | |
| задаем статические размеры. Количество div должно/желательно совпадать с количеством колонок*ряды. | |
| Либо мы должны вручную прописать что какието div будут занимать больше места.*/ | |
| /* | |
| указываем число колонок. можем использовать дополнительные функции такие как repeat, minmax. | |
| repeat - позволяет задать количество колонок и применяемые к ним свойства auto-fit/auto-fill | |
| auto-fit/auto-fill - браузер сам задает ширину и если нужно переносит колонки на новую строку. |
This file contains hidden or 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 path = require('path'); | |
| const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
| module.exports = { | |
| entry: { | |
| 'index': path.join(__dirname,'/src/index.js'), | |
| 'example1': path.join(__dirname,'/src/example1.js'), | |
| }, | |
| output: { | |
| filename: '[name].js', |
This file contains hidden or 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 getData(){ | |
| return fetch("http://jsonplaceholder.typicode.com/posts", { | |
| method: 'POST', // *GET, POST, PUT, DELETE, etc. | |
| mode: 'cors', // no-cors, cors, *same-origin | |
| cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached | |
| credentials: 'same-origin', // include, *same-origin, omit | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| // 'Content-Type': 'application/x-www-form-urlencoded', | |
| }, |
This file contains hidden or 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
| /*actoins тут мы создаем действия для нашего редьюсера*/ | |
| function nameOfAction(){ | |
| return {type:"NAME_OF_ACTION", payload:{name:"some object"} } | |
| } | |
| function addNewUser(){ | |
| return {type:"ADD_NEW_USER", payload:{id:11, name:"Zak"} } | |
| } | |
| function increment(){ | |
| return {type:"INCREMENT"} | |
| } |
NewerOlder