Skip to content

Instantly share code, notes, and snippets.

@gokulkrishh
Last active March 26, 2019 07:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gokulkrishh/14647db32a8d96542f8354dab8160e8d to your computer and use it in GitHub Desktop.
Save gokulkrishh/14647db32a8d96542f8354dab8160e8d to your computer and use it in GitHub Desktop.
Useful snippets for web development.
// 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