Utmaningar

F09-01: Which object is the "global object" in the browser?

  • document
  • window
  • object
  • module
Answer

window

F09-02: DOM is an abbreviation for....

  • Dynamic Object Moderation
  • Document Over Modulation
  • Document Object Model
  • Dynamic Over Mode
Answer

Document Object Model

F09-03: How many "Elements" does the snippet contain?

  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
Answer

Two elements. The P and A elements.

F09-04: How many "Nodes" does the snippet contain?

  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
Answer

6 noder. P-noden, A-noden, textnoden "Foo" samt tre tomma textnoder innehållande whitespaces.

F09-05: How many "attributes" does the snippet contain?

  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
Answer

2 attribut. "class" och "href"

F09-06: Which options do you have to select the li element containing the text node "Second one"?

  • document.querySelector('#SecondOne')
  • document.querySelectorAll('li')[1]
  • document.getElementById('numberlist').firstChild.nextSibling;
  • document.getElementById('numberlist').children[1]
Answer

document.querySelectorAll('li')[1] och document.getElementById('numberlist').children[1]

F09-07: How do you create a new ELEMENT_NODE using JavaScript? (Multiple choice)

  • document.createElement()
  • document.createTextNode()
  • anotherNode.cloneNode()
  • node:create "ELEMENT_NODE"
Answer
  • document.createElement()
  • anotherNode.cloneNode()

F09-08: Given HTML and CSS. Which class/classes is set on the div?

  • red, blue, tiger
  • blue, number, tiger
  • blue, tiger
  • red, number
  • number, red, blue, number, tiger
Answerblue number tiger

F09-09: Why do we use templates (<template>)?

  • Better performance than creating nodes using JavaScript.
  • They help us separate HTML from JavaScript.
  • It is a better version of Flash.
  • Templates are cached in the browser. JavaScript code is not.
AnswerThe help us separate html from js

F09-10: Why do we not want styling to be done in our JavaScript files? (multiple choice)

  • CSS generated from JavaScript will not be rendered
  • Modern browsers won´t accept CSS manipulation in JavaScript code as it opens up for security issues
  • Separation Of Concern is a design goal that simplifies the maintenance of an application
  • Designers would probably like to have CSS separated from JavaScript
Answer
  • Separation Of Concern is a design goal that simplifies the maintenance of an application
  • Designers would probably like to have CSS separated from JavaScript