comparison core-javascript/core-javascript-work/tutorial.js @ 140:abfb176c7346 core-javascript

Add Discussion and Explanation to bind-is-transient.rst.
author Jonathan Fine <jfine@pytex.org>
date Mon, 31 Oct 2011 20:41:47 +0000
parents de308579ea0d
children e8bfe6c50a01
comparison
equal deleted inserted replaced
139:de308579ea0d 140:abfb176c7346
94 return this; 94 return this;
95 }; 95 };
96 var obj = { 96 var obj = {
97 return_this : return_this 97 return_this : return_this
98 }; 98 };
99 assert( obj.return_this === return_this );
99 100
100 // Deferring method call changes the outcome. 101 // Deferring method call changes the outcome.
101 var method_deferred = obj.return_this; 102 var method_deferred = obj.return_this;
102 assert( method_deferred === obj.return_this ); 103 assert( method_deferred === obj.return_this );
103 assert( method_deferred() !== obj.return_this() ); 104 assert( method_deferred() !== obj.return_this() ); // AAA
104 105
105 // The two outcomes, precisely stated. 106 // The two outcomes, precisely stated.
106 assert( obj.return_this() === obj ); 107 assert( obj.return_this() === obj );
107 assert( method_deferred().telltail === 'global' ); 108 assert( method_deferred().telltail === 'global' );
109
110 // Another view on the matter.
111 assert( method_deferred === return_this );
112 assert( method_deferred() === return_this() ); // BBB
108 113
109 }); 114 });
110 // end transient-bind 115 // end transient-bind
111 116
112 117