Page 1: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics
- Objects in JavaScript are collections of properties, which can be either primitive values or other objects.
- Objects are created using curly braces, and their properties are defined using a key-value syntax.
- Properties can be accessed using dot notation or bracket notation, with the latter allowing for the use of variables as property keys.
- Objects can be used to group related data and functionality together, which can help with organization and code reuse.
- Objects can also be used to create complex data structures and algorithms, such as trees and graphs.
Page 2: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction
- The Document Object Model (DOM) is a programming interface for HTML and XML documents.
- The DOM represents a web page as a hierarchical tree of nodes, with each node representing an element, attribute, or piece of text within the document.
- JavaScript can be used to manipulate the DOM, allowing for dynamic and interactive web pages.
- DOM methods and properties can be used to select and modify specific elements within the page, create new elements, and respond to user events.
- The DOM provides a standard way of accessing and manipulating web page content, which makes it easier for web developers to write cross-browser compatible code.
Page 3: https://betterprogramming.pub/intermediate-javascript-whats-the-difference-between-primitive-values-and-object-references-e863d70677b
- In JavaScript, there are two types of values: primitive values and object references.
- Primitive values include numbers, strings, booleans, null, and undefined, and are immutable (i.e. their values cannot be changed).
- Object references, on the other hand, are mutable and refer to objects created using constructors or object literals.
- Object references allow multiple variables to refer to the same underlying object, which can be useful for sharing data between different parts of a program.
- However, object references can also make it more difficult to reason about code, as changes made to an object through one reference can affect other references to the same object.
Q: How would you describe an object to a non-technical friend you grew up with?
A: An object is a collection of related things with names.
Q: What are some advantages to creating object literals?
A: Object literals are easy to create and group related information together.
Q: How do objects differ from arrays?
A: Objects use named keys, while arrays use numbered indexes.
Q: Give an example for when you would need to use bracket notation to access an object’s property instead of dot notation.
A: When the property name contains special characters or is stored in a variable.
Q: Evaluate the code below. What does the term this refer to and what is the advantage to using this?
A: this
refers to person
, allowing the method to access and use its properties.
Q: What is the DOM?
A: The DOM is a programming interface for web documents.
Q: Briefly describe the relationship between the DOM and JavaScript.
A: JavaScript is used to manipulate the DOM for dynamic web pages.