Last active
May 7, 2018 08:36
-
-
Save goffreder/9955f88a8a39cb33e387 to your computer and use it in GitHub Desktop.
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
# Rompere tasto back: | |
window.history.pushState(0, window.location.href); | |
window.onpopstate = function() { | |
window.history.pushState(0, window.location.href); | |
}; | |
- versione minificata (61 chars): | |
(onpopstate=Function('history.pushState(0,location.href)'))() | |
# Log stack trace in un punto | |
- versione minificata (76 chars): | |
(function F(f){f.caller&&F(f.caller);console.log(f.name)})(arguments.callee) | |
# solo le proprietà di un oggetto dei tipi primitivi | |
function toPrimitives(obj) { | |
var o2 = {}; | |
Object.keys(obj).forEach(function(k) { | |
if(typeof obj[k] !== 'object' && typeof obj[k] !== 'function') | |
o2[k] = obj[k]; | |
}); | |
return o2; | |
} | |
# parsing cookies (ES5) | |
document.cookie.split(';').reduce((a,i)=>{a[(c=i.split('='))[0].trim()]=c[1].trim();return a},{}) | |
# (ES6) | |
document.cookie.split(';').reduce((a,i)=>({...a,[(c=i.split('='))[0].trim()]:c[1].trim()}),{}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment