On Wed, Jun 20, 2012 at 12:47 PM, Allen Wirfs-Brock <al...@wirfs-brock.com>wrote:
> yes, but in a static Java-like language such as for you example above, the > existence of person implies the existence of the getName method. The JS > equivalent would likely be something like: > Is it really rare to write JS code that assumes objects passed to it have an expected structure? Obviously, you don't have to, but when I have seen object-oriented code written in JS it tends to make such assumptions. If I write something that takes either null or a person object, I assume if it isn't null it really is a person object and I don't write checks to verify it. If someone passes something that doesn't have getName on it to my method, I am perfectly fine with it blowing up. When I expect that it might be null/undefined, then I have to write a bunch of boilerplate to deal with that, and ?. allows removing that boilerplate. -- John A. Tamplin Software Engineer (GWT), Google
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss