JavaScript Knowledge Flashcards

1
Q

What is a value in JavaScript? Give me an example

A

Its basically a piece of data, the most fundamental unit of information for programming. For example: A person’s name, a person’s age or person’s job. Can be within strings as well. Includes number as well. ‘Jonas’ or “Jonas”. 12, 14, 23 and etc.

In a JavaScript environment, those chunks are called values. Though all values are made of bits, they play different roles. Every value has a type that determines its role. Some values are numbers, some values are pieces of text, some values are functions, and so on. To create a value, you must merely invoke its name.

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

What is a Variable in JavaScript? Give me an example.

A

A variable stores the data value that can be changed. For example imagine a Variable like being a box, a box that can hold some object.

let firstName = “Jonas”; (firstName is the variable)

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

What does Camel case mean in JavaScript? Give an example.

A

Camel case means whenever we have multiple words in a variable name, write the first letter of the word as lower case, and then the next word on the first letter will be uppercase. For example:

console.log(firstName); (firstName being in camel case)

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

What do Variables only contain?

A

Numbers, letters, _ or the $

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

A Value is either an _____ or a _____ value.

A

an Object or a Primitive value

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

How many Primitive Data Types are there? Name them all.

A

There are 7 Primitive Data Types. Number, String, Boolean, Undefined, Null, Symbol (ES2015) and BigInt (ES2020).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
Define each Primitive Data Types.
Number
String
Boolean
Undefined
Null
Symbol
BigInt
A

Number- Floating point numbers, used for decimals and integer.
String- Sequence of characters, Used for text.
Boolean- Logical type that can only be true or false, Used for taking decisions.
Undefined- Value taken by a variable that is not yet defined. (empty value)
Null- Also means ‘empty value’
Symbol (ES2015)- Value that is unique and cannot be changed.
Bigint- Larger intergers than the Number type can hold.

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

What is dynamic typing? What does it mean?

A

That we can easily change the type of value that is held by a variable.

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

What types of operators are there?

A

Mathematical, comparison, logical

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

What is “string concatenation” mean? give me an example.

A

String concatenation is joining strings together.

console.log(“Hi, “ + firstName);

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

What is an “Array”?

A
// Array
const fruits = ["apples", "oranges", "pears", "bananas"];
const myArray = [21, "pear", [3, 7, 22], { objectsToo: true }];

Array: Used to store multiple values in a single variable. Similar to a list.

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

What is a “String Concatenation”

A

String concatenation is joining strings together.

console.log(“Hi, “ + firstName);

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

What is a Template Literal?

A

Template literals are a special type of string that make creating complex strings so much easier. Template literals are created by surrounding text between opening and closing backticks (``). Inside a template literal, you’re able to refer to variables or execute code by using ${}. Take a look at the following example:

console.log(10 + 25 = ${10 + 25}) // => “10 + 25 = 35”

By wrapping the calculation 10 + 25 in the ${}, we are able to calculate the total right there inside of the string. We can also refer to specific variables in a template literal as well:

const firstName = 'Kyle';
const greeting = `Hi, ${firstName}!`;
console.log(greeting); // => "Hi, Kyle!"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Exponentiation operator (**) and modulus (remainder) operator (%), describe each one.

A
-The exponentiation operator (**) raises the first number to the power of the second number.
2 ** 2 = 4
2 ** 3 = 8
2 ** 4 = 16
4 ** 4 = 256
-The modulus (remainder) operator (%) returns the remainder of dividing the first number by the second number.
4 % 2 = 0
4 % 3 = 1

4 % 5 = 4
In the first example, we get 0 because 2 divides evenly into 4, so there isn’t a remainder. In the second, we have a result of 1 since 3 goes into 4 one time and then leaves us with a remainer of 1.

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

What is an Assignment Operator?

A

to increase our value by more than 1 though? Luckily, there’s an operator for that as well! We call this an assignment operator.

let num = 5;

num += 10
console.log(num) // => 15

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