Created
March 19, 2017 15:02
-
-
Save bga/9c4af286f9bdeccdc3b890c7bacfb24c to your computer and use it in GitHub Desktop.
handy expr inspection for printf style debug.js
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
//# for printf style debugging | |
var inspect = function(v) { | |
console.dir(v) | |
return v | |
} | |
Object.defineProperty(Object.prototype, "inspect", { | |
value: function() { | |
console.dir(this) | |
return this | |
}, | |
enumerable: false, | |
configurable: true | |
}) | |
if(0) { | |
//# was | |
document.getElementsByTagName("ul").each(function(v) { | |
}) | |
//# want to inspect that ULs | |
//# just append { .inspect() } | |
document.getElementsByTagName("ul").inspect().each(function(v) { | |
}) | |
//# or wrap expr into { inspect(_) } if i care about native prototype purity | |
inspect(document.getElementsByTagName("ul")).each(function(v) { | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment