Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

javascript initialized objects (and the dom)

javascript initialized objects (and the dom)

Problem

What objects are created initially by compilers(?) of javascript?

I've been learning Io in order to understand prototyping languages. After doing a bit of research I've found the javascript 'Global Object'. What I can't seem to wrap my mind around is where the other built-in functions/prototypes/objects are coming from.

There is a print object and I have no clue where it was created. Was it created by the v8 engine I am using to run the javascript code?

And similarly, I'm a bit confused as to which objects are created in a Browser initially. I understand that the browser creates a dom in javascript. For example, the document object. But what other objects are there?

Also, in Io it is possible to view all objects that have been allocated memory. This is accessed through the Lobby. Is there something similar in javascript?

Problem courtesy of: jaredlwong

Solution

My favorite reference on javascript in a browser, global objects and DOM objects is MDN.

The browser creates a whole bunch of objects and makes them available for javascript access. They are created by the browser (not by the javascript engine as they aren't officially part of javascript), but the browser makes them accessible from javascript.

For example, the browser creates a document object, a window object which serves as the global object in the browser and adds a whole bunch of properties to the window object.

You can see a list of enumerable properties on the window object in your particular browser from this sample app: http://jsfiddle.net/jfriend00/nh39F/

Javascript, by itself, has some objects is creates just for it's own management of functionality. For example, there is usually a Math object that contains a bunch of math methods and a Date object that contains a bunch of date functionality.

Solution courtesy of: jfriend00

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

javascript initialized objects (and the dom)

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×