reading-notes

JavaScript Object Basics

  1. How would you describe an object to a non-technical friend you grew up with?

    • Objects are like sections of a library or areas of the gym. They are collections of related data/books/equipment/functionality. In tech terms they may consist of many variables (titles, equipment) and functions (techniques, chapters, machines/movement).
  2. What are some advantages to creating object literals?
    • they allow us to transfer a series of structured, related data items in a specific fashion. Perhaps sending a request to the server to be put into a database. Sending a single object is much more efficient than sending several items individually.
  3. How do objects differ from arrays?
    • Objects are easier to work with than an array when you want to identify an individual item by name.
  4. Give an example for when you would need to use bracket notation to access an object’s property instead of dot notation.
    • when an object property name is held in a variable
  5. Evaluate the code below. What does the term this refer to and what is the advantage to using this?
    • this refers to the current object the code is being written inside of.
    • in this case it is referring to the name and age specific to the variable const dog in the function.
    • the advantage is that you can reuse ${this.name} for every recurrence without having to change anything thus streamlining the code.

Introduction to the DOM (Document Object Model)

  1. What is the DOM?
    • programming interface for web docs
    • represents the page so that programs can change doc structure, style, content
    • nodes and objects allow programming languages to interact with the page
  2. Briefly describe the relationship between the DOM and JavaScript.
    • JavaScript wouldn’t have a model or notation of web pages, HTML docs, SVG docs, or their component parts without DOM
    • The document, the head, tables, table headers, text within table cells, and all elements are part of the DOM for that document
    • DOM is not part of the JS language
    • DOM is a Web API used to build websites
    • DOM is designed to be independent of any particular programming language for overall consistency