Skip to content

Instantly share code, notes, and snippets.

function f(str, seperator, limit) {
// split string by limit
// .split eventually add one more elements.
let arr = str.split(seperator, limit);
if(typeof limit === "number") {
// find last element's index, push it to the original array
let index = arr.reduce(function(prev, curr, i){
return str.indexOf(curr, prev);
}, 0);
@lukabot
lukabot / lazy.js
Created April 12, 2016 04:48 — 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;
};
}
@lukabot
lukabot / module_template.js
Created April 6, 2016 05:33
자바스크립트 모듈 패턴
/*
* 파일 이름, 목적, 작성자, 저작권 정보 및 기타 등등 적는곳
*
* module_template.js
* Template for browser feature modules
*
* Original Author
* Michael S. Mikowski - [email protected]
* Copyright (c) 2011-2012 Manning Publications Co.
*/