Featured post
JavaScript enum sample - how does this work? -
this bit of code this answer.
i'm trying understand how works i'm not getting all.
what think happening test_error closure errorvalue can't changed. 1 reference value this: test_error.success. please correct me if either of statements incorrect.
what don't understand return statement doing. it's returning object made of different errorvalues, returning what? , returning from? , when being called?
var test_error = (function() { function errorvalue(value, friendly) { this.value = value; this.friendly = friendly; } errorvalue.prototype = { tostring: function() { return this.friendly; }, valueof: function() { return this.value; } }; return { 'success': new errorvalue(0, 'success'), 'fail': new errorvalue(1, 'fail'), 'id_error': new errorvalue(2, 'id error') }; })();
thanks!
paul
test_error closure errorvalue can't changed.
test_error end being object specified in return statement inside anonymous function. this object can changed.
one reference value this: test_error.success
that's correct.
what don't understand return statement doing. it's returning object made of different errorvalues, returning what? , returning from? , when being called?
the return statement returning anonymous function that's declared with
(function() { ...})();
the ()
@ end means anonymous function being called immediately after declared, , value inside return
block assigned test_error
here's article on closures , emulating private variables might useful.
- Get link
- X
- Other Apps
Comments
Post a Comment