Intermediate JavaScript Flashcards
What is the DOM
Document Object Model
What is the Virtual DOM?
A virtual DOM is a lightweight JavaScript representation of the DOM used in declarative web frameworks such as React, Vue.js, and Elm. Updating the virtual DOM is comparatively faster than updating the actual DOM.
Window Object
Represents the browser window
Document Object
Represents the web page
Image Object
Represents an HTML IMG tag
History Object
Contains browser history
Navigator Object
Contains niformation about the visitor’s browser
All global JS objects, functions and variables automatically become….
members of the window object
Global variables (Window object) are…
properties of the window object
Global functions (window object) are..
methods of the window object
Some methods of the Window Object
window. open
window. close
window. moveTo
window. resizeTo
Finding HTML (Document Object), few examples
getElementsById
getElementsByTagName
getElementsByClassName
Changing HTML (Document Object)
element. innerHTML =
element. attribute =
element. setAttribute (attribute,value)
Adding or Deleting Elements (Document Object)
document. createElement(element)
document. removeChild(element)
document. appendChild(element)
Event Handler (Document Object)
document.getElementById(id).onclick = function () {code}
Create an Image Object
const x = document.createElement(“IMG”)
Some Image Object properties
complete
naturalHeigth
naturalWidth
src
Image rollover?
Two images. Change onMouseOver and onMouseOut
Return the anchor part of a URL (Location Object)
var x = location.hash;
Which Methods are there for the Location Object?
assign() Loads a new document
reload() Reloads the current document
replace() Replaces the current document with a new one
Difference between replace or assign (location object)
After using replace the current page will not be saved in the session history
Which Navigator propertie returns the version of the browser?
appVersion
Which Navigator object returns the operating system?
platform
Which Navigator property returns the name of the browser?
appName
Which three methods to extract a part of String are there?
slice(start, end)
substring(start, end)
substr(start, length)
What does slice()? (String)
extracts a part of a string and returns the extracted part in a new string.
What doest the substring() method?
substring() is similar to slice().
The difference is that substring() cannot accept negative indexes.
What does the substr() method?
substr() is similar to slice().
The difference is that the second parameter specifies the length of the extracted part.
Difference between indexOf() and search() method?
The search() method cannot take a second start position argument. The indexOf() method cannot take powerful search values (regular expressions).
String.match….
The match() method searches a string for a match against a regular expression, and returns the matches, as an Array object.