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
// scrollbar | |
// firefox | |
.textarea { | |
scrollbar-color: transparentize($color-titanic, 0.92) transparent; | |
scrollbar-width: thin; | |
} | |
// the rest, besides IE | |
.textarea::-webkit-scrollbar-track |
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
/* | |
Differences & Limitations: | |
Does not have its own bindings to this or super, and should not be used as methods. | |
Does not have arguments, or new.target keywords. | |
Not suitable for call, apply and bind methods, which generally rely on establishing a scope. | |
Can not be used as constructors. | |
Can not use yield, within its body. | |
*/ |
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++; |
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
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
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
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
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 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 Calculator() { | |
this.operations = { | |
'+': (a, b) => +a + +b, | |
'-': (a, b) => a - b, | |
}; | |
this.validateInputNumbers = function(arr) { | |
return !(isNaN(arr[0]) || isNaN(arr[2])) | |
}; | |
NewerOlder