Last active
December 15, 2015 15:39
-
-
Save magnetikonline/5283391 to your computer and use it in GitHub Desktop.
Google Closure JavaScript compiler optimization examples.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a statement like this... | |
if (fruit == 'apples') fruit = 'bananas'; | |
// is converted to this... | |
'apples'==fruit&&(fruit='bananas'); | |
// next... a statement like this... | |
if (fruit !== undefined) callMe(); | |
// is converted to this... | |
if(void 0!==fruit)callMe(); | |
// truthy values | |
var myVariable = true; | |
// are converted to this... | |
myVariable=!0; | |
// pre-calculated math | |
var COOKIE_LIFETIME_DAYS = 30, | |
expireUTC = new Date(); | |
// calculate expiry time for cookie | |
expireUTC.setTime( | |
expireUTC.getTime() + | |
(COOKIE_LIFETIME_DAYS * 24 * 60 * 60 * 1000) // hours * minutes * seconds * microseconds | |
); | |
// is converted to this | |
var b=new Date;b.setTime(b.getTime()+2592E6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment