Skip to content

Instantly share code, notes, and snippets.

@severuykhin
severuykhin / OOP1.js
Created April 2, 2017 13:33
JavaScript OOP examples
function CoffeMachine(power){
const _this = this; //Сохранение контекста для обрращения к нему из внутренних функций
//Set water amount
this.waterAmount = 0;
const WATER_HEAT_CAPACITY = 4200;
var timerId;
@severuykhin
severuykhin / debounce.js
Created April 2, 2017 12:29
Converts several function calls within a certain time into one call
var debounce = function (f, ms){
var state = null;
var COOLDOWN = 1;
return function(){
if(state) return;
f.apply(this. arguments);
@severuykhin
severuykhin / count.js
Last active January 24, 2017 15:51
Script fo animated counters and onetime called function
function countDown(start, end, item) {
var startFrom = start;
var timer = setInterval(function(){
startFrom += 1;
item.innerHTML = startFrom;
if(startFrom >= end){clearInterval(timer)}
}, 10);
}