javascript - what exactly is the DOM? and what is an object as taken from the DOM? -
i know bit of javascript , have started trying tie html code academy course. in following code:
function sayhello(name){ document.getelementbyid("result").innerhtml = 'hello ' + name + '!'; }
the "document" in above code dom?
that mean getelements property (function) of document, , innerhtml function of getelements function.... right?
if seeing correctly, how possible dom objects have javascript properties/functions?
is document
dom
short answer
yes, in sense root of it.
slightly longer answer
the document object model (dom) browser exposes javascript runtime allow javascript code manipulate page (its nodes , associated metadata). document
1 part of dom.
how can dom have javascript properties
short answer
they don't.
slightly longer answer
the dom not managed in javascript (yet). typically managed separate engine altogether, written in lower-level language c++ or rust (in case of mozilla's servo project). javascript runtime also written in lower-level language (again, c++ likely) , attributes of dom exposed javascript runtime as if native javascript objects. fact not makes kinds of interesting things possible ... , make these dom objects do not behave expect "real" javascript objects behave (for example typeof queryselectorall
in ie 8 returns "object", not "function" 1 reasonably expect).
Comments
Post a Comment