Javascript Flashcards

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
Q

How to write a double (either or) condition

A

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

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

What is pseudo code and why is it important?

A

Being able to talk out what you want your code to do, and then coding it.

Allows you to code in any language.

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

How to declare and assign multiple variables at once?

A

Let user = ‘ John ‘
, age = 25
, message = ‘ yellow ‘ ;

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

Let message = ‘ hi ‘ ;

Let message = ‘ hey ‘ ;

Why would this error?

A

Only declare a variable once; don’t use let twice.

29
Q

Const hi = ‘ 3.14 ‘ ;

Const hi = ‘4.56’ ;

Why would this error?

A

A Const can NEVER be re-assigned. It never changes.

30
Q

When would we use upper case in our Constants names?

A

On variables that are super hard to remember but are know BEFORE execution.

Ex. Hexadecimal numbers.

31
Q

When naming your variables, what are the two rules?

A
  1. Only letters, numbers and the TWO symbols ( $ and _ )
  2. First character of name CANT be a number
32
Q

What are the 2 types of constants?

A

Constants that are know PRIOR TO EXECUTION (ex. A birthday)

Constants that are CALCULATED IN RUN_TIME (ex. Loading time)

33
Q

What’s a function?

A

Function = A set of codes to perform a task ( ex. Eat = go to kitchen, prepare food, chew, swallow…)

34
Q

What is the syntax of a function?

A

Function + name of function ( parameter1, parameter 2… ) {
Function body
}

35
Q

When thinking about functions, what are global vs local variables? What is the best practice for using each?

A

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
Q

When you have two variables with the same declaration (one local and one outer variable), which variable will the function use?

A

The local (inside) variable.

37
Q

What are parameters in functions?

A

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
Q

When using functions, what are parameters vs arguments?

A

Parameters = the tools a function will use to do its job.

Arguments = the materials you give the function to use with its parameters.

39
Q

How to set the default parameter when you don’t provide an argument?

A

Function functionName ( parameter = “ default setting “ ) {

40
Q

What is the basic structure of naming a function. Give example.

A

Prefix verb + “what”

Ex. calcSum

41
Q

What are common prefix names for functions?

A

Get = return a value
Calc = calculate
Create
Check

42
Q

Is it good or bad to make your function do more than one action?

A

Bad. One function = one action.

43
Q

What is “self-describing” code?

A

You keep functions really simple and accurately named. No functions with more than one action.

Makes better organization & easy to read/understand later

44
Q

Better to use local or global variables for functions?

A

Local = better = better organization & cleaner code

45
Q

What is x ! = 8

A

X is not equal to 8

46
Q

X = = 8 means…

A

X equals 8 (in terms of value)

47
Q

What is x = = = “3” mean

A

X is exactly equal to (value and type)

48
Q

What is x ! = = “3” mean

A

X is not equal (neither value nor type)

49
Q

X! = = 3 vs x ! = = “ 3 “

A

Quotes = a string

No Quotes = an integer

50
Q

X > 8 means…

A

X is greater than 8

51
Q

What does x < 8 mean?

A

X is less than 8

52
Q

X > = 8 means…

A

X is greater than or equal to 8

53
Q

X < = 8 means….

A

X = is less than or equal to 8

54
Q

What are logical operators?

A

Relationships in conditionals. Ex. X = = = “3”

55
Q

When writing conditionals, how many else if’s can you have? What happens to the code if you have multiple else if’s?

A

You can have infinite else if’s. If multiple, the code will move in sequential order.

56
Q

What does the = mean in JavaScript?

A

= means your assigning something in a variable

57
Q

Explain the “danger of assignment vs comparison”

A

Be careful using = in your comparisons/conditionals. Only ONE = will mean assignment.

58
Q

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.

A

Document . Queryselector ( ‘ #ID of insert location ‘ ) . InnerText = ` $ { Input ID 1 } $ { input ID 2} `

59
Q

What’s pseudo code? How do you do it? Why is it important?

A

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
Q

How to write a comment in JS?

A

Start with //

61
Q

How to write a class in JS

A

‘Classname’

62
Q

What does this mean:

Variable. Classlist. Toggle ( ‘hidden ‘ )

A

Toggle = change from on to off ( or opposite)

‘ hidden ‘ = a class

63
Q

In Java script, what are you telling the computer to do with this code?

“ document. Queryselector ( ‘ # check ‘ ) . AddEventListener ( ‘ click ‘ , check )

A

“ 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
Q

what is a function expression. give an example

A

When you create a variable and assign it a FUNCTION.

let sayHi = function ( ) {…

65
Q

how are function expressions different from normal functions

A

Because function expressions are assigned to variables, they don’t have their own name. Its just function:

let sayHI = function ( )

66
Q

why do function expressions have a ; at the end?

A

because the ; is part of a normal variable assignment syntax.

ex. let name = function; just like

let name = 2;

67
Q

what are callback functions?

A

putting functions inside other functions

68
Q

dogage++ vs ++ dogage

A

dogage ++ = variable total plus 1

++ dogage = 1 plus doggage