Created
November 29, 2012 07:38
-
-
Save jeffreyiacono/4167410 to your computer and use it in GitHub Desktop.
define a log property on the window (or global) obj in js
This file contains hidden or 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
| // via https://gist.github.com/4080907 | |
| Object.defineProperty(window, 'log', { | |
| set: function(args) { | |
| console.log.apply(console, Array.isArray(args) ? args : [args]); | |
| this.value = args | |
| }, | |
| get: function() { | |
| return this.value + " from .get"; | |
| } | |
| }); | |
| log = 'abc'; | |
| log = [1,2,3,4]; | |
| console.log(log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment