Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
54 Cards in this Set
- Front
- Back
Is JavaScript case sensitive?
|
Yes
|
|
What do statements end with in JavaScript?
|
;
|
|
How do you comment in JavaScript?
|
// = single line
/* this is a multi- line comment */ |
|
How do you integrate JavaScript into a block of HTML?
|
<script>
|
|
Are there variable "types" in JavaScript?
|
No. JS is a weakly typed language, so it's agnostic on type.
|
|
What is the syntax of an if loop?
|
if (condition) {
//code block evaluated if the condition is true //code block is skipped if the condition is false } |
|
What is the difference between parentheses, brackets and braces?
|
parentheses ()
brackets [] braces {} |
|
Strict equality
|
===
used to evaluate two variables. It evaluates them at the "type" level. |
|
Equality
|
==
evaluates two variables (used in condition statements). Does not evaluate at the "type" level. |
|
Assigning or setting a value
|
=
used to set values |
|
Not equal
|
!=
Used in condition statements |
|
Not strictly equal
|
!==
used in condition statements |
|
Order of operations for JS
|
+ - * /
|
|
Logical "and" gate
|
&&
used in condition statements. allows one to evaluate multiple conditions in a single line. |
|
Logical "or" gate
|
||
used in condition statements. allows one to evaluate multiple conditions in a single line. |
|
How can you increment a value "i" by 1?
|
i++ since the code reads left to right, this statement does not initially increment i. It increments it after the statement has been evaluated.
++i This statement increments i the first time around. i += 1 This statement increments i the first time around. |
|
How can you de-increment a value "i" by 1?
|
i--
--i i-=1 Same rules as incrementing. |
|
What is a ternary operator? Please display the syntax of such an operator.
|
A ternary operator is a syntax expression for a basic conditional expression.
(condition) ? (what happens if the condition is true?) : (what happens if the condition is false); |
|
What is necessary for a loop to work properly?
|
1. Index or counter (usually "i")
2. Something that checks the condition 3. Increment the index |
|
While loop syntax
|
while (condition) {
//code to evaluate while the condition remains true //code block incrementing the value }; |
|
Do While loop syntax
|
do {
//code block with incrementing value } while (condition); |
|
For loop syntax
|
for ( index; condition checker; incrementor) {
//code block }; |
|
What is a code break? What is the syntax?
|
A code break allows for one to "break" out of a loop. Upon evaluation, it will skip to the code immediately after the loop.
syntax: break; |
|
What is a "continue" in a code block?
|
If evaluated during a loop, "continue;" will break the sequence of the current iteration of a loop, and begin evaluating from the top of the loop again.
|
|
What is a function in JavaScript?
|
A block of code that will be executed when someone calls on it. It can accept parameters. Usually, these are defined at the top of a JS document.
|
|
What is the syntax of a function in JavaScript?
|
function functionName( parameters, are, separated, by, commas, no_parameters_required) {
//code } |
|
Can a JS function return information?
|
Yes, but it is not required to return anything.
|
|
What happens if you provide a mismatched number of variables to a JS function?
|
Missing variables will be left as undefined. if your code can run with undefined variables, it will work. If not, it will not work.
Extra variables will simply be ignored. |
|
What is a local variable?
|
A variable that exists only within a function.
|
|
What is a global variable?
|
A variable that exists within the whole document of code.
|
|
What is an array?
|
It is an object.
It is used to store multiple values in a single variable. |
|
What indicates an array (3 ways)?
|
1. []; square brackets
2. new Array(); 3. Array(); var variableName = [bla, bla, bla, 3, bla, bla, "hi"]; |
|
Can you have an empty array?
|
yes, you can populate an array later. For example:
var VariableName = []; VariableName[0]=50; VariableName[1]="Taylor"; etc... |
|
What are some methods for the array object?
|
variablename.join()
variablename.sort() variablename.length() variablename.reverse() |
|
how do you collect tag names from an HTML document and store them in a variable named "myArray"?
|
var myArray = document.getElementsByTagName("a");
//this code will find all "a" tags from the document "document" and place them in an array |
|
NaN
|
Not a Number (output when a math expression didn't make sense)
|
|
function isNaN(variable);
|
returns true if the "variable" is not a number
returns false if the "variable" is a number |
|
function !isNaN(variable);
|
returns true if the "variable" is a number
returns false if the "variable" is not a number //easier to comprehend with the double negative //ask yourself, is "variable" a number? |
|
what is "Math" in JavaScript? (object or method)
|
Object
|
|
what is the escape sequence for a quote?
|
" bla bla bla \"this is something i put in quotations\" bla bla bla."
|
|
What is a string in javascript? (method or object)
|
Object
|
|
What does the ".split" method do to a string?
|
Splits the words of a string. makes an array of the words...
|
|
what is "Date" in javascript? (method or object?)
|
Object
|
|
What will console.log(Date()) output in mozilla?
|
The current timestamp to the millisecond
|
|
Var today = new Date();
today.getMonth(); //what will this return? |
returns month (0-11)
|
|
Var today = new Date();
today.getFullYear(); //what will this return? |
returns YYYY (not zero based)
|
|
Var today = new Date();
today.getDate(); //what will this return? |
returns the day of the month
|
|
Var today = new Date();
today.getDay(); //what will this return? |
returns 0-6 (day of the week)
|
|
Var today = new Date();
today.getHours(); //what will this return? |
returns hours (24)
|
|
What is a document in JS?
|
(Object) It is the root node of an HTML document and the "owner" of all other nodes.
|
|
What is an object in JS?
|
A special kind of data with properties and methods
|
|
What is a method in JS?
|
Actions that can be performed on objects
objectName.methodName() .join .slice .indexOf .push .splice etc... |
|
What is a property in JS?
|
Values associated with an object
objectName.propertyName .value .length .name .constrictor etc... |
|
What are the four steps towards creating a DOM element (using the example of a new text node)
|
1. Create variables for the new elements
var newHeading = document.createElement("H1"); 2. Create new variables (nodes) for the text of the new element var newText = document.createTextNode("Did you know?"); 3. Append the text nodes with the new elements newHeading.appendChild(newText); 4. Append the new element with the document document.getElementById("trivia").appendChild(newHeading); //appends the new element to a specified spot in the document ("trivia") |