Skip to content

Instantly share code, notes, and snippets.

@collinglass
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collinglass/2674d49a6c0248449e27 to your computer and use it in GitHub Desktop.
Save collinglass/2674d49a6c0248449e27 to your computer and use it in GitHub Desktop.
javascript snippets
// function to deep copy an object
function deepCopy(object) {
return JSON.parse(JSON.stringify(object));
}
// wrapper function to call a function once
function once(fn, context) {
var result;
return function() {
if(fn) {
result = fn.apply(context || this, arguments);
fn = null;
}
return result;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment