JavaScript FreeCodeCamp Flashcards

(45 cards)

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
typeof "3"
returns "string"
26
!=
Inequality operator. Returns true if values are not equal.
27
!==
Strict Inequality operator. Will not convert data types.
28
&&
Logical and operator. Returns true if both operands are true
29
||
Logical or operator. Returns true if either of the operands are true.
30
``` var myObj = { prop1: "val1", prop 2: "val2" }; ```
creates an object
31
myObj.prop1
returns the value in prop1 in the object myObj
32
myObj["Space Name"]
returns the value in "Space Name" in the object myObj
33
delete ourDog.bark;
removes "bark" property from object ourDog
34
myObj.hasOwnProperty("propName");
Returns true if the object has the given property
35
JSON
JavaScript Object Notation
36
while (i < 5) { ourArray.push(i); i++; }
while loop. Runs while a specified condition is true.
37
for (initialization; condition; final expression) { }
a for loop that runs for a specified number of times
38
``` var i = 0; do { ourArray.push(i); i++; } while (i < 5); ```
Do-while loop. Runs the code at least once before checking the condition to see if it continues.
39
Math.random()
function that generates a random decimal number between 0 (inclusive) to 1 (exclusive)
40
Math.floor(num)
function that rounds the number down to a whole number
41
Math.floor(Math.random() * 20)
gives a whole number between 0 and 19
42
Math.floor(Math.random() * (max - min + 1)) + min
returns a whole number between min and max, inclusive
43
parseInt("")
function that parses a string and returns the corresponding integer
44
parseInt(string, radix)
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
condition ? statement-if-true : statement-if-false;
conditional operator. A one line if-else expression