Javascript gid

From John Freier
Jump to: navigation, search

This is a function for generating an id.

 /**
  * Create a uniqe id.
  * Example: ae7d31a6-e955-8e2e-ebf5-8863ed74e55d
  */
 function guid() {
 	function s4() {
     	return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
   	}
   	return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
 }