Skip to content

Instantly share code, notes, and snippets.

@bga
Created March 19, 2017 15:02
Show Gist options
  • Save bga/9c4af286f9bdeccdc3b890c7bacfb24c to your computer and use it in GitHub Desktop.
Save bga/9c4af286f9bdeccdc3b890c7bacfb24c to your computer and use it in GitHub Desktop.
handy expr inspection for printf style debug.js
//# 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