JavaScript FreeCodeCamp Flashcards

1
Q

// This is a comment

A

Single line comment

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

/* This is a multi-line comment */

A

multiple line comment

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

NaN

A

not a number

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

sometimes referred to as floating point numbers or floats

A

decimal numbers

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

myVar % 2 = 1

A

Checks to see if myVar is odd. 1 = odd, 0 = even

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

var sampleStr = “Alan said, "Peter is learning Javascript".”;

A

use \ to signal that “ should appear inside the string

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

\n

A

newline

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

\t

A

tab

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

\b

A

word boundary

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

\f

A

form feed

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

firstName.length

A

returns the number of characters in the string in firstName

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

zero-based indexing

A

programming languages start counting at 0

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

var lastLetter = firstName[firstName.length - 1];

A

returns the last character in the string firstName

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

multi-dimensional array

A

[[“Bulls, 23], [“White Sox”, 45]]

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

myArray[0] = 15;

A

arrays are mutable and entries can be changed freely

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

myArray[3][0][1]

A

equals the #3 entry, #0 entry in that array, and #1 entry in that array

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

myArray.push(4);

A

appends 4 to the end of the array

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

myArray.pop();

A

removes the last element from an array and returns that element

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

myArray.shift();

A

removes the first element from an array and returns it

20
Q

myArray.unshift(4);

A

adds element to the beginning of the array

21
Q

function testFun(param1, param2) { }

A

creates a reusable function that takes parameters (arguments)

22
Q

==

A

equality operator. Returns true if both values are equal.

23
Q

===

A

Strict equality operator. Will not perform data type conversion.

24
Q

typeof 3

A

returns “number”

25
Q

typeof “3”

A

returns “string”

26
Q

!=

A

Inequality operator. Returns true if values are not equal.

27
Q

!==

A

Strict Inequality operator. Will not convert data types.

28
Q

&&

A

Logical and operator. Returns true if both operands are true

29
Q

||

A

Logical or operator. Returns true if either of the operands are true.

30
Q
var myObj = { 
 prop1: "val1", 
 prop 2: "val2"
};
A

creates an object

31
Q

myObj.prop1

A

returns the value in prop1 in the object myObj

32
Q

myObj[“Space Name”]

A

returns the value in “Space Name” in the object myObj

33
Q

delete ourDog.bark;

A

removes “bark” property from object ourDog

34
Q

myObj.hasOwnProperty(“propName”);

A

Returns true if the object has the given property

35
Q

JSON

A

JavaScript Object Notation

36
Q

while (i < 5) {
ourArray.push(i);
i++;
}

A

while loop. Runs while a specified condition is true.

37
Q

for (initialization; condition; final expression) { }

A

a for loop that runs for a specified number of times

38
Q
var i = 0;
do {
  ourArray.push(i);
  i++;
} while (i < 5);
A

Do-while loop. Runs the code at least once before checking the condition to see if it continues.

39
Q

Math.random()

A

function that generates a random decimal number between 0 (inclusive) to 1 (exclusive)

40
Q

Math.floor(num)

A

function that rounds the number down to a whole number

41
Q

Math.floor(Math.random() * 20)

A

gives a whole number between 0 and 19

42
Q

Math.floor(Math.random() * (max - min + 1)) + min

A

returns a whole number between min and max, inclusive

43
Q

parseInt(“”)

A

function that parses a string and returns the corresponding integer

44
Q

parseInt(string, radix)

A

Parses the string and returns an integer. The radix specifies the base number of the string. The radix can be an integer between 2 and 36.

45
Q

condition ? statement-if-true : statement-if-false;

A

conditional operator. A one line if-else expression