DOM Manipulation

(Assignments here & here)

Tutorials 

Problem Set

Blog Questions

  • querySelector( ) allows the selection of an element by any CSS selector, while querySelectorAll( ) allows the selection of a set of elements by any CSS selector.
  • Four examples to select this element are:
<p id="one" class=".main">This awesome paragraph!</p>

var select1 = document.querySelector("#one")
var select2 = document.querySelector(".main")
var select3 = document.querySelector("p")
var select4 = document.querySelectorAll("p")[0]

Javascript Objects

(Assignments here & here)

Tutorials 

Problem Set

Blog Questions

  • Reddit uses an array of objects.
var redditPosts = [
    {
        post_type: "Info Thread",
        post_title: "Questions & Suggestions Thread",
        post_link: "https://www.reddit.com/r/nbastreams/comments/beh7dn/questions_suggestions_thread/",
        post_points: 139,
        post_subreddit: "r/nbastreams",
        post_author: "u/invmini",
        time_posted: value, //value based on created time function
        post_comments: [] //array of comments with this post
    }
]

Javascript Arrays

(Assignments here & here)

Tutorials 

Problem Set

Blog Questions

  • Array method pop( ) removes the last value in the array and returns the value that was removed. Array method push( ) inserts a value into the last spot in the array and returns the total number of values in the array. Array method shift( ) removes the first value in the array and returns the value that was removed. Array method unshift( ) inserts a value into the first spot in the array and returns the total number of values in the array.
var array = [ "a", "b" , "c"]
undefined
array.push("d")
4
array.pop()
"d"
array.shift()
"a"
array.unshift("a")
3
array
(3) ["a", "b", "c"]
  • I believe BleacherReport uses an array of data to store the different articles that are presented on the page.