W3. The DOM Flashcards
1
Q
How does parameter passing work in JS for base types and object types?
A
Base types (String, Number, Boolean) passed by value. Object types (Object, Function, Array) passed by reference. (Parameters are un-typed)
2
Q
What does DOM stand for?
A
Document Object Model
3
Q
In the DOM, what does the Window object refer to?
A
- The OS window hosting the page
- global object in JS program when it is executed in a browser
- contains other objects including document, navigator and screen and references to other windows and frames
4
Q
In the DOM, what does the Navigator object refer to?
A
Browser application in use Includes: - name of browser - platform (e.g MacIntel) - language of browser (e.g. english) - if browser is online - geolocation - cookie info
5
Q
In the DOM, what does the Screen object refer to?
A
Physical monitor in use Properties: - width - height - colourDepth - pixelDepth etc.
6
Q
In the DOM, what does the Document object refer to?
A
- currently displayed HTML
- root of the DOM tree (parent of tag)
- always directly accessible via JS
(lots of methods e.g. getElementById)
7
Q
In the DOM, what does the Node class refer to?
A
Class that most objects in DOM inherit from Properties: - childNodes - firstChild - lastChild - nextSibling - parentNode etc.
8
Q
What does JSON stand for?
A
JavaScript Object Notation
9
Q
What is JSON used for?
A
- syntax for storing and exchanging data
- text, written with JS object notation
- easy conversion from/to JS objects
- can be sent between browser and server
10
Q
What 2 methods are there for converting between JSON and JS?
A
.stringify - to convert to a JSON string
.parse - to convert to a JS object
11
Q
What is a WebSocket?
A
- provides (full-duplex) communication over a TCP connection between web browser and web server
(data moves in both directions)
12
Q
How do WebSockets allow two-way communication between client and server?
A
- have a standardised way of allowing the server to send content to the client without it first being requested by client
13
Q
List 4 WebSocket events
A
- on open
- on error
- on close
- on message