On Mon, May 28, 2012 at 9:33 PM, John Tamplin <[email protected]> wrote: > On Tue, May 29, 2012 at 12:07 AM, John J Barton > <[email protected]> wrote: >> >> function app() { >> var r = makeExample(); >> r.discover = function() { >> console.log("I want to call this function"); >> return 1; >> }; >> r.discover(); >> } >> >> The result is an error message at the >> Uncaught TypeError: Object #<Object> has no method 'discover'. > > > Isn't this code broken in either case?
Yes, this is correct. > The only question is whether you get > an exception when you create discover() or when you call it. Your code can > choose or not to treat adding properties to frozen objects as a fatal error > or not, but the code is going to fail if r is frozen no matter what. This is not correct. (Well to be sure, I am assuming that you meant to write: "You can choose..." because, of course, 'code' cannot choose.) I do not have this choice. I wrote the code and I got the error. Here is where I am asking you to imagine the real-life situation, not the exercise of a few lines of code. If I had a magic translation book that said "oh, you know that Uncaught TypeError: Object #<Object> has no method 'discover', really means you tried to modify a frozen object", then I would have a choice. No such book exists to the best of my knowledge. jjb > > -- > John A. Tamplin > Software Engineer (GWT), Google _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

