Skip to content

Instantly share code, notes, and snippets.

@aNd1coder
Last active August 29, 2015 14:04
Show Gist options
  • Save aNd1coder/352acd2312a12dc16cb6 to your computer and use it in GitHub Desktop.
Save aNd1coder/352acd2312a12dc16cb6 to your computer and use it in GitHub Desktop.
javascript utility function
// Add commas to numbers
function addCommas(n) {
return String(n).replace(/(\d)(?=(\d{3})+$)/g, '$1,')
}
//check the browser environment
function isWeiXinEnv(){
var ua = window.navigator.userAgent.toLowerCase();
return ua.match(/MicroMessenger/i) == 'micromessenger';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment