Why is the JavaScript textContent property safer than innerHTML?

textContent changes the text of the target, while innerHTML can include HTML tags. This makes it easier for someone to pass malicious code into your project through an unsanitized input box.

Explain the relationship between an HTML attribute and a corresponding DOM property (explain the connection to JavaScript). Use a specific example in your answer.

Each HTML attribute has a corresponding DOM property that can be manipulated with JavaScript. If one is changed, usually the other gets changed as well. HTML attributes are not the only things that are properties, however. innerHTML is a DOM property that changes the HTML inside the element it is called on. Many of their names are one to one: style in HTML is style in DOM, href is href, etc. Some, however, are not one to one, like class. Class in HTML becomes className in JavaScript for historical reasons.

What is a JavaScript method? Define and provide two examples.

Methods--also called functions--are essentially a shorthand for a list of code to be executed. That way, you do not have write that list a bunch of times. Just write it once and call back to it whenever you need it. Some examples are console.log() and Number().

What is a JavaScript property? Define and provide two examples.

A JavaScript property is a way to change an HTML attribute. For example, you could use the property "href" to change the corresponding HTML attribute. In the same vein, you could use innerHTML with JavaScript to change the HTML inside the node you are working with.

What is a JavaScript object? Define and provide two examples.

An object is a data type that can contain all sorts of things: methods, variables, even other objects. One example would be the document object that contains all things relating to the document like HTML tags and their objects. Another example would be style which is an object that can be used with anything that can be styled.

What is a CSS selector? Define and provide two examples.

A CSS selector is what goes before the curly braces in CSS. A few examples are a:hover (a pseudo-class), #wrapper (an id), or .heading (a class).

What is a CSS property? Define and provide two examples.

A CSS property is what you want to style. Some examples are z-index, color, and font-family.

What is a CSS declaration? Define and provide two examples.

A CSS declaration is a combo of a CSS property and a value. It looks like "property: value;". A few examples are "color: red;", "font-family: Garamond;", and "padding: 10px;".

Placeholder

Major

Major

Major