Skip to content

Instantly share code, notes, and snippets.

@gthrm
Last active September 16, 2019 19:10
Show Gist options
  • Save gthrm/5ed52c1ea84b0b425939d436cc39b5da to your computer and use it in GitHub Desktop.
Save gthrm/5ed52c1ea84b0b425939d436cc39b5da to your computer and use it in GitHub Desktop.
Bufer
const bufer = (function makeBufer() {
let cash = '';
function fn(value) {
if (!value) {
return cash;
}
cash += value;
}
fn.clear = () => {
cash = '';
}
return fn
})();
bufer('TS');
bufer('JS');
console.log(bufer());
bufer.clear()
console.log('После ', bufer());
const bufer = makeBufer()
function makeBufer() {
let cash = '';
function fn(value) {
if (!value) {
return cash;
}
cash += value;
}
fn.clear = () => {
cash = '';
}
return fn
}
bufer('TS');
bufer('JS');
console.log(bufer());
bufer.clear()
console.log('После ', bufer());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment