Skip to content

Instantly share code, notes, and snippets.

View savelichalex's full-sized avatar

Alexey Savelev savelichalex

View GitHub Profile
@savelichalex
savelichalex / lazy.js
Created December 26, 2015 10:24 — forked from kana/lazy.js
Lazy evaluation in JavaScript
function delay(expressionAsFunction) {
var result;
var isEvaluated = false;
return function () {
if (!isEvaluated)
result = expressionAsFunction();
return result;
};
}