Skip to content

Instantly share code, notes, and snippets.

@Samjin
Samjin / Scroll() event optimization
Last active July 5, 2016 06:34
Scroll() event optimization
var throttle = (function () {
return function (fn, delay) {
delay || (delay = 100);
var last = +new Date;
return function () {
var now = +new Date;
if (now - last > delay) {
fn.apply(this, arguments);
last = now;
}
@Samjin
Samjin / Facade example
Created May 3, 2016 18:01
Facade simple exmaple
var module = (function() {
var _private = {
i:5,
get : function() {
console.log( "current value:" + this.i);
},
set : function( val ) {
this.i = val;
},