Reading-Notes

Reading Notes

Reading

JavaScript Object Basics

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

An object, in coding terms, is like a box. The only thing you put in this box is specific information or data. For example if you are making a box for personel information maybe you have a piece of paper that has the information you want stored such as first name, last name, birthday, and what their favorite dinosaur is, but you can also have a list of all their favorite foods on there too. Then you put it in the box so that you can reference the information later.

What are some advantages to creating object literals?

They are easy to reference and work with using simple syntax. They are easier to work with than a bunch of single items or even an array.

How do objects differ from arrays?

It’s a dfferent referencing system, instead of using an index number you call it something and then reference it by name.

Give an example for when you would need to use bracket notation to access an object’s property instead of dot notation.

“…if an object property name is held in a variable, then you can’t use dot notation to access the value, but you can access the value using bracket notation.” https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics

Evaluate the code below. What does the term this refer to and what is the advantage to using this?

const dog = {

name: ‘Spot’,

age: 2,

color: ‘white with black spots’,

humanAge: function (){ console.log(${this.name} is ${this.age*7} in human years); } }

“this” is used as an immediate reference point to whatever the item is (ie: name, age) within the system of the object. It tells the code to only search among the box of the object. The “this” makes it so that you can go within many objects and pull out that same specific information respective to each without having to write code specific to each object, instead one line can be universal to all.

Introduction To The DOM

What is the DOM?

“The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document.”

The HTML DOM is a standard object model and programming interface for HTML. It defines:

https://www.w3schools.com/js/js_htmldom.asp

Briefly describe the relationship between the DOM and JavaScript.

JavaScript is a language and the document object model is a book? The language can also be used in other contexts like being spoken, however, when it exsists in a book it has a certain set of rules and behavior guidelines regarding how it is written and read.

Bookmark and Review

Understanding the problem domain is the hardest part of programming

What’s the difference between primitive values and object references in JavaScript?

===> So these last two aren’t questions, and one isn’t even a link to anything. I’m just gonna turn this in and read the remaining link then.