Private Slots

Nathan Wall nathan.wall at live.com
Mon Jan 14 19:29:27 PST 2013


> Regardless of the "this" binding, the privately keyed method will not 
> be copied over from the source object and hence will be undefined when 
> called. 

I think you're not understanding. Here's a simpler example that runs in modern ES engines:

    var A = {
        foo: function() {
            console.log('foo');
        },
        bar: function() {
            console.log('bar');
            this.foo();
        }
    };

    var B = { };
    B.bar = A.bar.bind(A);

    B.bar();

This logs "bar" and then "foo", so foo is correctly called, even though it is not a method of B. 		 	   		  


More information about the es-discuss mailing list