3 ms·
He can save 14 more if instead of creating a function he copies the function content inside of 'onclick'. And he can save one by using +new Date instead of Date
by ivanca 11y ago
He can save 14 more if instead of creating a function he copies the function content inside of 'onclick'. And he can save one by using +new Date instead of Date.now().
- sgibat 11y agoBetter yet, set a variable to Date.now since it's called twice.
- ajanuary 11y agoIt's called at different times so will return different values, which is important.
- ahoge 11y agoThey meant something like "var n = Date.now". However, there is no guarantee that this will work since it assumes that `this` isn't used by that function. E.g. if you want to do something like that with console.log or document.querySelector, you have to use bind: var log = console.log.bind(console); var qs = document.querySelector.bind(document);
- roberto 11y agoa = Date.now; b = a(); c = a();