On 13/Dec/10 11:57 PM, Rajat wrote:
Hi,I was trying something today when this occurred to me : var a = {}; function mutate(obj){ obj = function(){ alert('hey'); }; } mutate(a); a(); Firebug throws the following error: TypeError: a is not a function. I want to understand why we can change the passed object inside mutate by lets say adding more properties to it but not this way where I am redefining it as a function object. I hope my question is clear. Thanks,
Hopefully, you're question is just out of curiosity and not because you'd want to use such a feature. That code base would be really hard to maintain. Explicit is better than implicit. If you want `a` to hold a new value, then just reassign it.
-- IonuČ› G. Stan | http://igstan.ro -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
