Javascript Flashcards

1
Q

What are the 6 types of values in JavaScript?

A
Numbers,
Strings,
Booleans,
Objects,
Functions,
Undefined
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What type of operator is this: =

A

Assignment operator, Assigns value to a variable

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

What type of operator is this: +

A

Addition operator, adds values

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

What type of operator is this: -

A

Subtraction operator, subtracts values

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

What type of operator is this: /

A

Division operator, divides values

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

What type of operator is this: %

A

Remainder operator, divides values and gives back the remainder.

Example: 27 % 16 = 11. Because 27 / 16 = 1 with a remainder of 11.

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

What type of operator is this: ++

A

Increment operator, adds 1 to its operant and returns the value

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

What operator is this: –

A

Decrement operator, subtracts 1 from its operant and returns the value

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

What is an operand?

A

An operand is a value that is being acted upon by an operator

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

String

A

Used to represent text. Written in quote marks.

Ex: “This is a string”

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

\ ~In the context of a string~

A

Escaping. This signifies in a string that the next character is important.

Ex: “This is a "quote"”
Result: This is a “quote”

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

\n

A

New line
Ex: “Hello Top \nHello Bottom”
Result: Hello Top
Hello Bottom

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

\t

A

Tab in a string.

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

\

A

Backslash in a string

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

"

A

Quote marks in a string.

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

Concatenation

A

Adding strings together.
Ex: “Con” + “cat” + “e” + “nate”
Result: Concatenate

17
Q

Boolean Values

A

Values that are true or false.

18
Q

Comparison operators

A
> Greater than
< Less than
>= Greater than or equal to
<= less than or equal to
== equal value
=== equal value and type
!= not equal to
19
Q

True or false? Strings can be compared using comparison operators?

A

Kind of true. They can be compared in alphabetical order based on the Unicode order.

20
Q

Logical Operators

A

And (&&), Or(||), Not(!)

21
Q

And operator

A

&&

Result is true if both values are true

22
Q

Or operator

A

||

Result is true if either value is true.

23
Q

Not operator

A

!

Result is flipped.
Ex:

!true = false

Ex2:

!false = true

24
Q

True or False: Undefined and Null are essentially the same.

A

True

25
Q

What is an expression?

A

A fragment of code that produces a value. Every value written literally i.e. “Cat” or 22.

26
Q

What is a variable and what is the keyword that indicates a variable?

A

A variable is used to store a value for further manipulation. The key word is var.

Ex: var Cat = “kitten”;

27
Q

An = cannot be used on an existing variable to disconnect it from its current value, true or false?

A

False. An = can be used at any time to disconnect it from its current value.

28
Q
var luigisDebt = 140;
 luigisDebt = luigisDebt - 35;
 console.log(luigisDebt);

What should this program output?

A
  1. (Refer to Notebook #1 page 14-15 for notes)
29
Q

Confirm(“text”);

What does this do?

A

Brings up a pop up confirmation box.

30
Q

Prompt(“Where are you from?”);

What does this do?

A

It pulls up a pop up with a prompt asking “Where are you from?” And provides a text field for entry.

31
Q

What does console.log() do?

A

It takes whatever is inside the parentheses and logs it to the console below your code. Also called printing out.

32
Q

Write a program that if “WordLength” is greater than or equal to 10 then the console output is “That is a long word!”

Hint: Use if statement.

A

If (“wordlength.length >= 10) {
console.log(“That is a long word!”);
}

33
Q

What does else do?

A

For an if statement an else outputs a given output if the condition being closeted by the if is false.

34
Q

How do you use substring?

A

Substring coordinates work like this.
(1,4) The 1 means to start counting on the 2nd character of the string and the 4 means to count 4 characters from that point.

Ex: “Batman”.substring(0,3);

Would be “Bat”.