Basic JavaScript Instructions Flashcards
textContent vs. innerHTML
textContent outputs text/plain while innerHTML outputs text/html
Statement
A statement is an individual instruction that the computer should follow. Each one should start on a new line and end with a semicolon.
The semicolon also tells the JavaScript interpreter when a step is over, indicating that it should move to the next step.
Code Block
Some statements are surrounded by curly braces; these are known as code blocks. The closing curly brace is not follow by a semicolon.
Variable
var quantity = 3;
Data Types
A temporary storage of information
keyword, name, assignment operator, value;
numbers, strings, booleans
Array
Literal vs. Constructor
An array is a special type of variable that stores a list or a set of values that are related to each other.
var colors = [“white”, “black”, “custom”];
var colors = new Array(“white”, “black”, “custom”);
Expression
An expression evaluates into (results in) a single value.
Operators
Types
Expressions rely on things called operators; they allow programmers to create a single value from one or more values.
assignment
- color = “beige”;
arithmetic
- area = 3 * 2;
string
- greeting = “Hi “ + “Molly”;
comparison
- buy = 3 > 5;
logical
- buy = (5 > 3) && (2 < 4);