Javascript Flashcards

(68 cards)

1
Q

What is JavaScript?

A

High level language that humans understand, that can be broken down into basic computer language (binary code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the DOM

A

Document object model = everything in inspector is NOT the HTML / CSS. It is the RENDERING of these files.

You can manipulate the DOM (rendering of files) via JavaScript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens to the DOM when you refresh a webpage?

A

the DOM (document object model) resets completely and starts from scratch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does JavaScript affect our HTML / CSS codes.

A

JavaScript manipulates and changes the way a DOM is rendered, not the files. JS works on the browser itself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What’s an event listener?

A

Sensors in your DOM that respond to specific stimulus and activate a specific program/code action in response.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

4 key aspects to know in JavaScript

A

Variables, conditionals, functions, loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are variables

A

What we can use to tell program to store/remember a value for use later on.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a declaration

A

What we use to create a space in memory

Ex. “ let age “

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What’s an assignment

A

Assignment = action of setting a unit/info to a declaration/memory bucket.

Ex . Age = 25

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What 2 steps of a variable? Give example

A
  1. Create a space in memory (declaration)
  2. Assign a value (assignment)

Let age = 25

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are variable conventions? Ex. Camel case

A

The way to write variables.

Camel case = first word low caps

Next words = upper case first letters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What two common types of data can you store in your variables?

A

Numbers
Strings (pieces of text)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are strings? How to write them?

A

Piece of text, surrounded by double quotes, single quotes, or ticks (all preference)

What you use on outside CANT be used on inside:

Example : ‘They “purchased” it’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

If you want to use double quotes, how to escape that?

A

Put back slash \ before each quote:

“They \”purchased\” it”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What 2 kinds of numbers in JavaScript?

A

Integers (isn’t) : 29 (whole numbers)

Float: 5.19398 (number with decimal places)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What signs for multiply? Division? Modulus?

A

Multiply *
Divide /
Modulus %

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is 10 mod 4?

A
  1. (4 goes into 10 twice with 2 left over)

Mod = modulus = remainders.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are conditionals in JavaScript?

A

If - condition = activate program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does “ x = = 3 “ mean? How is it different from x = = = 3

A

Two = means equal in VALUE

Three = means equal in Value and TYPE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What does ! Mean in “ x ! = 8

A

! = not

X doesn’t not equal 8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is conditional syntax?

A

If ( condition is true ) {
/ / do cool stuff
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How to program multiple conditionals : if the first doesn’t work..

A

If ( condition is true ) {
Do this cool stuff
} else if (condition is true ) {
Do this other cool stuff )
} else {
Do default stuff
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Const vs let

A

Const = Constance (never changing variable_)

Let = variable that can change or be re-assigned

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How to write a double conditional? (2 conditions at one time)

A

If ( condition 1 && condition 2 ) {
Action
}

Must use 2 ampersands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
How to write a double (either or) condition
If ( condition 1 || condition 2 ) { Action }
26
What is pseudo code and why is it important?
Being able to talk out what you want your code to do, and then coding it. Allows you to code in any language.
27
How to declare and assign multiple variables at once?
Let user = ‘ John ‘ , age = 25 , message = ‘ yellow ‘ ;
28
Let message = ‘ hi ‘ ; Let message = ‘ hey ‘ ; Why would this error?
Only declare a variable once; don’t use let twice.
29
Const hi = ‘ 3.14 ‘ ; Const hi = ‘4.56’ ; Why would this error?
A Const can NEVER be re-assigned. It never changes.
30
When would we use upper case in our Constants names?
On variables that are super hard to remember but are know BEFORE execution. Ex. Hexadecimal numbers.
31
When naming your variables, what are the two rules?
1. Only letters, numbers and the TWO symbols ( $ and _ ) 2. First character of name CANT be a number
32
What are the 2 types of constants?
Constants that are know PRIOR TO EXECUTION (ex. A birthday) Constants that are CALCULATED IN RUN_TIME (ex. Loading time)
33
What’s a function?
Function = A set of codes to perform a task ( ex. Eat = go to kitchen, prepare food, chew, swallow…)
34
What is the syntax of a function?
Function + name of function ( parameter1, parameter 2… ) { Function body }
35
When thinking about functions, what are global vs local variables? What is the best practice for using each?
Global = variables created outside function Local = variables created inside of function. - try to minimize use of global variables. Creating mostly local variables inside functions = better organization.
36
When you have two variables with the same declaration (one local and one outer variable), which variable will the function use?
The local (inside) variable.
37
What are parameters in functions?
Information you want the function to use, when it is running it’s code. Ex. Function adder ( num1, num2 ) { Console . Log ( num1 + num 2 ) ; } Adder ( 5 , 10 ) * function will now add 5 + 10
38
When using functions, what are parameters vs arguments?
Parameters = the tools a function will use to do its job. Arguments = the materials you give the function to use with its parameters.
39
How to set the default parameter when you don’t provide an argument?
Function functionName ( parameter = “ default setting “ ) {
40
What is the basic structure of naming a function. Give example.
Prefix verb + “what” Ex. calcSum
41
What are common prefix names for functions?
Get = return a value Calc = calculate Create Check
42
Is it good or bad to make your function do more than one action?
Bad. One function = one action.
43
What is “self-describing” code?
You keep functions really simple and accurately named. No functions with more than one action. Makes better organization & easy to read/understand later
44
Better to use local or global variables for functions?
Local = better = better organization & cleaner code
45
What is x ! = 8
X is not equal to 8
46
X = = 8 means…
X equals 8 (in terms of value)
47
What is x = = = “3” mean
X is exactly equal to (value and type)
48
What is x ! = = “3” mean
X is not equal (neither value nor type)
49
X! = = 3 vs x ! = = “ 3 “
Quotes = a string No Quotes = an integer
50
X > 8 means…
X is greater than 8
51
What does x < 8 mean?
X is less than 8
52
X > = 8 means…
X is greater than or equal to 8
53
X < = 8 means….
X = is less than or equal to 8
54
What are logical operators?
Relationships in conditionals. Ex. X = = = “3”
55
When writing conditionals, how many else if’s can you have? What happens to the code if you have multiple else if’s?
You can have infinite else if’s. If multiple, the code will move in sequential order.
56
What does the = mean in JavaScript?
= means your assigning something in a variable
57
Explain the “danger of assignment vs comparison”
Be careful using = in your comparisons/conditionals. Only ONE = will mean assignment.
58
You want to create a code that takes values from different inputs and combines them together into a string and inserts it into another place.
Document . Queryselector ( ‘ #ID of insert location ‘ ) . InnerText = ` $ { Input ID 1 } $ { input ID 2} `
59
What’s pseudo code? How do you do it? Why is it important?
Pseudo code = being able to talk ABOUT your code. How = talk out what you want to do and WRITE it. Important because will allow you to program in any language.
60
How to write a comment in JS?
Start with //
61
How to write a class in JS
‘Classname’
62
What does this mean: Variable. Classlist. Toggle ( ‘hidden ‘ )
Toggle = change from on to off ( or opposite) ‘ hidden ‘ = a class
63
In Java script, what are you telling the computer to do with this code? “ document. Queryselector ( ‘ # check ‘ ) . AddEventListener ( ‘ click ‘ , check )
“ hey. Go to the DOM, and look (queryselector) for a code with the ID, “Check”, put an event listener on it. When it senses a click, activate the “check” function.
64
what is a function expression. give an example
When you create a variable and assign it a FUNCTION. let sayHi = function ( ) {...
65
how are function expressions different from normal functions
Because function expressions are assigned to variables, they don't have their own name. Its just function: let sayHI = function ( )
66
why do function expressions have a ; at the end?
because the ; is part of a normal variable assignment syntax. ex. let name = function; just like let name = 2;
67
what are callback functions?
putting functions inside other functions
68
dogage++ vs ++ dogage
dogage ++ = variable total plus 1 ++ dogage = 1 plus doggage