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 TextField from '@material-ui/core/TextField'; | |
import Autocomplete from '@material-ui/lab/Autocomplete'; | |
export default function ComboBox(props) { | |
return ( | |
<Autocomplete | |
autoHighlight={props.autoHighlight} | |
onChange={props.handleChange} | |
clearText={props.clearText} |
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
class Group { | |
constructor() { | |
this.elements = []; | |
} | |
add(element) { | |
if (!this.has(element)) { | |
this.elements.push(element); | |
} | |
} |
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 Calculator() { | |
this.operations = { | |
'+': (a, b) => +a + +b, | |
'-': (a, b) => a - b, | |
}; | |
this.validateInputNumbers = function(arr) { | |
return !(isNaN(arr[0]) || isNaN(arr[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 loopSumTo(n) { | |
let sum = 0; | |
for (let i = n; i >= 1; i--) { | |
sum += i; | |
} | |
return sum; | |
} |
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 spy(func) { | |
wrapper.calls = []; | |
function wrapper() { | |
wrapper.calls.push([...arguments]); | |
func(...arguments); | |
} | |
return wrapper; | |
} |
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 throttle(f, ms) { | |
return function updater() { | |
if (updater.ready === false) { | |
updater.args = arguments; | |
return; | |
} | |
updater.ready = false; | |
f.apply(this, arguments); |
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
class Clock { | |
constructor({ template }) { | |
this.template = template; | |
} | |
stop() { | |
clearInterval(this.timer); | |
}; |
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 obj = { | |
length: 4, | |
0: 'one', | |
1: 'two', | |
2: 'three', | |
}; | |
console.log(Array.from(obj, (v, i) => { | |
if (v === undefined) { | |
return 'no element'; |
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 sum(a, b, c) { | |
return a + b + c; | |
} | |
function curry(func) { | |
return function curried(...args) { | |
if (args.length >= func.length) { | |
return func.apply(this, args); |
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
// если в колбеке setTimeout используем this, то нужно либо привязка bind, либо стрелочная функция, | |
// так как setTimeout вызывает колбек в другом контексте и this внутри функции будет глобальным объектом | |
// wrong | |
var obj = { | |
count : 10, | |
doSomethingLater : function (){ | |
setTimeout(function(){ // the function executes on the window scope | |
this.count++; |
OlderNewer