Subj : Re: updated jsgen (maybe rc1?) - beta 7 To : netscape.public.mozilla.jseng From : Brendan Eich Date : Mon Jan 05 2004 09:59 am This is a multi-part message in MIME format. --------------000604060009070101090701 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Brendan Eich wrote: > You want some notion of "scope" that can be deduced from an object. > The way in JS (even ECMA has this, for function objects -- see the > [[Scope]] internal property) is to walk up the parent chain from the > object till you find an object with null parent. That's the "global > scope" for the object you started from, and that's the object in which > class-named constructors or prototypes are defined by JS_InitClass. So here's the ASCII-art diagram that attempts to depict JS's object model. Hope it helps, /be --------------000604060009070101090701 Content-Type: text/plain; name="JSOM.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="JSOM.txt" (null) | +----------------+ |Object.prototype|==================++ +----------------+ || ^ ^ || +-----------------+ | || | | vv | +------------------+ +-------------+ | |Function.prototype|==========>|global object| | +------------------+ _+------------- _ | ^ __/ ^^ ^^ \_ | | __'f' || || \_ | +--------------+<--. || || \ | |function f(){}|==================++ || | | +--------------+ || 'o' | || | +----------------------+ || _/ |var o = {p:'hi', q:42}|=======================================++ _/ +----------------------+<--. _/ \________________________________________/ Legend: ^ ^^ .--> __proto__ | __parent__ || property __'id'__/ | ===++ _/ Not shown: property arcs from global object to Object and Function. --------------000604060009070101090701-- .