iegorov
3/7/2014 - 2:22 AM

Underscore.js and guid function (http://jsbin.com/kuruzasu/1/edit)

Underscore.js and guid function (http://jsbin.com/kuruzasu/1/edit)

_.mixin({
        guid : function(){
          return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
            var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
            return v.toString(16);
          });
        }
      });