Created
January 14, 2012 03:48
-
-
Save mde/1610175 to your computer and use it in GitHub Desktop.
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
> var foo = {a: function () { console.log(this.b); }, b: true}; | |
> foo.b; | |
true | |
> foo.a; | |
[Function] | |
> foo.a(); | |
true | |
> var bar = foo.a; | |
> foo; | |
{ a: [Function], b: true } | |
> bar; | |
[Function] | |
> bar(); | |
undefined | |
> var b = 'hello'; | |
> bar(); | |
hello | |
> var baz = {b: false}; | |
> bar.call(baz); | |
false | |
> var proxy = function (obj, func) { return function () { func.apply(obj, arguments) } }; | |
> var qux = proxy(baz, bar); | |
> qux(); | |
false | |
> var a = {}; | |
> typeof a; | |
'object' | |
> var b = function () {}; | |
> var c = new b(); | |
> typeof c; | |
'object' | |
> c; | |
{} | |
> var b = function () { return {a: true} }; | |
> var c = new b(); | |
> c; | |
{ a: true } | |
> var c = b(); | |
> var b = function () {}; | |
> var c = b(); | |
> typeof c; | |
'undefined' | |
> var c = new b(); | |
> typeof c; | |
'object' | |
> var c = new (function () {})(); | |
> typeof c; | |
'object' | |
> var foo = 'myString'; | |
> var bar = {]; | |
... | |
> var bar = {}; | |
> bar[foo] = 'hello'; | |
'hello' | |
> bar; | |
{ myString: 'hello' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment