Skip to content

Instantly share code, notes, and snippets.

@zzuhan
Created November 3, 2013 15:20
Show Gist options
  • Save zzuhan/7291368 to your computer and use it in GitHub Desktop.
Save zzuhan/7291368 to your computer and use it in GitHub Desktop.
create unique cid learn from underscore.js
var uniqueId = function () {
var idCounter = 0;
return function(prefix){
var id = ++idCounter + '';
return prefix ? prefix + id : id;
}
}();
var cid = uniqueId(); // 1
var maskCid = uniqueId('mask') //mask2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment