How to add dots every 3 digits in currency values with JavaScript

If you’re European like me, you’re probably used to this notation: € 366.432 instead of 366,432 or 366432. In order to get this done in JavaScript you want to do the following: // Number var money = 366432; // Convert to String and add dots every 3 digits var moneyDots = money.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, “$1.”); // Set […]

Simple iPhone5 detection with JavaScript

It’s really simple, just use this function: function isIphone5(){ function iOSVersion(){ var agent = window.navigator.userAgent, start = agent.indexOf( ‘OS ‘ ); if( (agent.indexOf( ‘iPhone’ ) > -1) && start > -1) return window.Number( agent.substr( start + 3, 3 ).replace( ‘_’, ‘.’ ) ); else return 0; } return iOSVersion() >= 6 && window.devicePixelRatio >= 2 […]