Skip to content

Instantly share code, notes, and snippets.

@pinalbhatt
Last active May 28, 2016 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pinalbhatt/1ed36b319301aac7ecbc to your computer and use it in GitHub Desktop.
Save pinalbhatt/1ed36b319301aac7ecbc to your computer and use it in GitHub Desktop.
JavaScript Snippets
// Empty an Array http://davidwalsh.name/empty-array
myArray = []; // bad
myArray.length = 0; // good!
//http://www.w3schools.com/js/js_performance.asp
//bad
for (i = 0; i < arr.length; i++) {}
//good
var l = arr.length;
for (i = 0; i < l; i++) {}
/*
Writing Fast, Memory-Efficient JavaScript
https://www.smashingmagazine.com/2012/11/writing-fast-memory-efficient-javascript/
*/
/*
10 Javascript Performance Boosting Tips from Nicholas Zakas
http://jonraasch.com/blog/10-javascript-performance-boosting-tips-from-nicholas-zakas
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment