Last active
March 26, 2019 07:46
-
-
Save gokulkrishh/14647db32a8d96542f8354dab8160e8d to your computer and use it in GitHub Desktop.
Useful snippets for web development.
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
// Add any library to application | |
((library = 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.min.js') => { | |
var element = document.createElement('script'); | |
element.src = library; | |
element.type = 'text/javascript'; | |
document.head.appendChild(element); | |
})(); | |
// Trace any properties | |
const traceProperty = (object, property) => { | |
let value = object[property]; | |
Object.defineProperty(object, property, { | |
get () { | |
console.trace(`${property} requested`); | |
return value; | |
}, | |
set (newValue) { | |
console.trace(`setting ${property} to `, newValue); | |
value = newValue; | |
}, | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment