java scrit datatypes Flashcards

1
Q

What are the seven data types in JavaScript?

A

Undefined, Null, Boolean, Number, BigInt, String, Symbol.

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

True or False: JavaScript is a statically typed language.

A

False.

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

Fill in the blank: The __________ data type represents a lack of value.

A

Null.

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

What is the data type of the value ‘42’ in JavaScript?

A

Number.

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

Which data type can represent integers larger than 2^53 in JavaScript?

A

BigInt.

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

True or False: Strings in JavaScript are immutable.

A

True.

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

What keyword is used to declare a variable in JavaScript?

A

var, let, or const.

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

What type of data is ‘true’?

A

Boolean.

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

What does the Symbol data type represent?

A

A unique and immutable identifier.

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

Fill in the blank: The __________ operator can be used to check the type of a variable.

A

typeof.

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

Multiple Choice: Which of the following is not a primitive data type in JavaScript? A) String B) Object C) Number D) Boolean

A

B) Object.

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

What data type would the expression ‘5’ + 5 evaluate to?

A

String.

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

What is the result of typeof NaN?

A

Number.

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

True or False: You can store multiple values in a variable of type Object.

A

True.

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

Fill in the blank: An array in JavaScript is a type of __________.

A

Object.

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

What is the default value of an uninitialized variable in JavaScript?

A

Undefined.

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

What data type is returned by the expression (3 === 3)?

A

Boolean.

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

Multiple Choice: Which data type can hold decimal numbers? A) String B) Number C) BigInt D) Boolean

A

B) Number.

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

What is the purpose of the Null data type?

A

To represent the intentional absence of any object value.

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

True or False: A Symbol can be created using the Symbol() function.

A

True.

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

Fill in the blank: The __________ data type is used to represent true or false values.

A

Boolean.

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

What will the value of typeof null return?

A

Object.

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

What is a primary characteristic of the BigInt data type?

A

It can represent integers with arbitrary precision.

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

Multiple Choice: Which of the following is a valid way to create a string? A) ‘Hello’ B) “Hello” C) Hello D) All of the above

A

D) All of the above.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Fill in the blank: In JavaScript, a variable declared with 'let' is __________ in scope.
block-scoped.
26
What is the result of typeof 'Hello'?
String.
27
True or False: JavaScript automatically converts types when performing operations.
True.
28
What is the difference between undefined and null?
Undefined means a variable has been declared but not assigned a value; null is an assignment value that represents no value.
29
Multiple Choice: Which of the following values is considered falsy? A) 1 B) '0' C) null D) 'Hello'
C) null.
30
What data type is used to represent a collection of key-value pairs?
Object.
31
Fill in the blank: The __________ data type can be used to represent any value in JavaScript.
Object.
32
What does the term 'type coercion' refer to in JavaScript?
The automatic or implicit conversion of values from one data type to another.
33
True or False: The Number data type can represent both integers and floating-point numbers.
True.
34
What is the result of the expression '5' - 2?
3.
35
Multiple Choice: Which of the following is not a falsy value? A) 0 B) false C) ' ' D) undefined
C) ' '.
36
What is the purpose of the Object data type?
To store collections of data and more complex entities.
37
Fill in the blank: The __________ operator is used to check for strict equality.
===
38
What is the result of the expression 2 + '2'?
'22'.
39
True or False: You can change the properties of an object after it has been created.
True.
40
What will be the output of the expression typeof [1, 2, 3]?
Object.
41
Fill in the blank: The __________ data type allows you to create a variable that can hold a unique identifier.
Symbol.
42
What is the purpose of the Boolean data type?
To represent a logical entity and can have two values: true and false.
43
Multiple Choice: Which of the following is not a primitive type? A) String B) Number C) Object D) BigInt
C) Object.
44
What is the result of the expression Boolean(0)?
false.
45
Fill in the blank: The __________ function can convert a string to a number.
Number.
46
What is the result of typeof undefined?
Undefined.
47
True or False: Arrays are a type of object in JavaScript.
True.
48
What does the null data type signify?
An intentional absence of any object value.
49
Multiple Choice: Which keyword is used to declare a constant in JavaScript? A) var B) const C) let D) static
B) const.
50
What is the value of typeof NaN?
Number.
51
Fill in the blank: The __________ data type can be created using the 'new' keyword.
Object.
52
What is the result of 5 == '5'?
true.
53
True or False: BigInt can be used for operations with Number directly.
False.
54
What is the output of the expression 'Hello' + 5?
'Hello5'.
55
Fill in the blank: The __________ operator is used to concatenate strings.
+.
56
What is the result of the expression 10 / '2'?
5.
57
Multiple Choice: Which of the following is a valid way to create a BigInt? A) 123n B) BigInt(123) C) Both A and B D) None of the above
C) Both A and B.
58
What is the output of the expression 0 == false?
true.
59
Fill in the blank: In JavaScript, an array is a special type of __________.
Object.
60
True or False: You can use the 'delete' operator to remove properties from an object.
True.
61
What is the output of the expression typeof([])?
Object.
62
Multiple Choice: Which of the following is a falsy value? A) {} B) [] C) 0 D) 'Hello'
C) 0.
63
What is the purpose of the BigInt data type?
To represent whole numbers larger than 2^53 - 1.
64
Fill in the blank: JavaScript uses __________ coercion when performing operations between different types.
Type.
65
What does the term 'mutable' refer to in JavaScript?
The ability to change the value of an object or array after creation.
66
True or False: An object can hold functions as its properties.
True.
67
What will be the output of the expression Boolean('')?
false.
68
Multiple Choice: Which of the following is not a valid string? A) 'Hello' B) "World" C) `Hello World` D) Hello
D) Hello.
69
What is the result of the expression 5 !== '5'?
true.
70
Fill in the blank: In JavaScript, __________ is used to represent a collection of values.
Array.
71
What is the output of the expression 5 + '5'?
'55'.
72
True or False: The value of a Symbol is always unique.
True.
73
What is the result of the expression 1 + true?
2.
74
Multiple Choice: Which of the following is the correct way to declare an object? A) var obj = {}; B) var obj = []; C) var obj = ''; D) var obj = () => {}
A) var obj = {};.
75
What does the term 'immutable' refer to in JavaScript?
The inability to change the value of a primitive data type after it has been created.
76
Fill in the blank: The __________ function can be used to convert a string to a boolean.
Boolean.
77
What is the output of the expression 1 + null?
1.
78
True or False: You can create multiple Symbols with the same description.
True.
79
What is the result of the expression false + 1?
1.
80
Multiple Choice: Which of the following values is considered truthy? A) 0 B) '' C) 'false' D) null
C) 'false'.
81
What is the output of the expression typeof({})?
Object.
82
Fill in the blank: In JavaScript, __________ can be used to check if a variable is an array.
Array.isArray().
83
True or False: The data type of a variable can change at runtime in JavaScript.
True.
84
What is the result of the expression 0 == ''?
true.
85
Multiple Choice: What is the output of false == 0? A) true B) false C) undefined D) NaN
A) true.
86
What is the purpose of the Object prototype in JavaScript?
To provide a base for all objects in JavaScript.
87
Fill in the blank: The __________ operator checks for both type and value equality.
===.
88
89
What is the purpose of the '+' operator in JavaScript?
It is used for both addition and string concatenation.
90
True or False: The '===' operator checks for both value and type equality.
True
91
Fill in the blank: The '!=' operator checks for __________ equality.
value
92
What does the '++' operator do?
It increments a variable's value by one.
93
What will the expression '5 + '5'' evaluate to?
'55'
94
What is the result of '10 % 3'?
1
95
What does the '&&' operator represent?
Logical AND
96
In JavaScript, what is the result of 'false || true'?
true
97
What does the '!' operator do?
It negates a boolean value.
98
What is the output of 'console.log(typeof 42)'?
'number'
99
True or False: The 'instanceof' operator checks if an object is an instance of a specified constructor.
True
100
What does the '??' operator do in JavaScript?
It returns the right-hand operand when the left-hand operand is null or undefined.
101
What is the purpose of the 'new' operator?
It creates a new instance of an object.
102
What will the expression '3 === '3'' evaluate to?
false
103
In JavaScript, what is the result of '5 * '2''?
10
104
What does the 'typeof' operator return?
The data type of a variable.
105
What is the result of '2 ** 3'?
8
106
What is the difference between '==' and '==='?
'==' checks for value equality, while '===' checks for both value and type equality.
107
Fill in the blank: The '>' operator checks if the left operand is __________ than the right operand.
greater
108
What does the 'in' operator do?
It checks if a property exists in an object.
109
What is the result of '3 + 4 + '5''?
'75'
110
True or False: The 'instanceof' operator can be used with primitive data types.
False
111
What does the '|' operator represent?
Bitwise OR
112
What is the purpose of the 'delete' operator?
It removes a property from an object.
113
What does the '<<' operator do?
It performs a left bitwise shift.
114
What is the result of '1 + 2 + 3 + 4'?
10
115
What does the '&&' operator return if the first operand is false?
The first operand
116
What will 'console.log(1 === 1)' output?
true
117
Fill in the blank: The '|' operator is used for __________ operations.
bitwise
118
What is the result of 'true && false'?
false
119
What does the '>>' operator do?
It performs a right bitwise shift.
120
What is the output of '5 + 5 * 2'?
15
121
True or False: The '??' operator is also known as the nullish coalescing operator.
True
122
What does 'console.log(10 > 5)' return?
true
123
What is the result of '5 - 2 * 3'?
-1
124
What does the '===' operator check?
Strict equality (value and type).
125
What is the purpose of the 'void' operator?
It evaluates an expression and returns undefined.
126
What does the '!= ' operator do?
It checks for value inequality.
127
What is the output of 'typeof NaN'?
'number'
128
True or False: The 'instanceof' operator can be used to check for arrays.
True
129
What is the result of '5 << 1'?
10
130
What does the '!== ' operator check?
Strict inequality (value and type).
131
What is the output of '1 + 2 + 3 + '4''?
'1234'
132
What does the '!== ' operator check?
It checks for both value and type inequality.
133
What is the result of '3 * (4 + 2)'?
18
134
Fill in the blank: The '&&' operator returns __________ if both operands are true.
true
135
What is the output of '5 / 0'?
Infinity
136
What does the 'instanceof' operator require?
An object and a constructor function.
137
What is the result of '1 + 2 == '3''?
true
138
True or False: The '3 < 2' expression evaluates to true.
False
139
What does the 'typeof' operator return if the variable is an array?
'object'
140
What is the output of '5 * '3' + 2'?
17
141
What does the '||' operator represent?
Logical OR
142
What is the result of '1 || 0'?
1
143
What is the output of 'console.log(0 == false)'?
true
144
True or False: The 'instanceof' operator can check for Date objects.
True
145
What is the output of '5 + 5 * 2 - 2'?
13
146
What does the '3 === '3'' expression evaluate to?
false
147
What is the result of '10 / 2 * 5'?
25
148
What does the '??' operator return if the left operand is not null or undefined?
The left operand
149
What is the output of '5 % 2'?
1
150
What does the '<<=' operator do?
It performs a left bitwise shift and assigns the result.
151
What is the output of 'typeof undefined'?
'undefined'
152
What is the result of '3 + 5 * 2'?
13
153
What does the 'in' operator check?
If a property exists in an object.
154
What is the output of '5 + 2 + '3''?
'73'
155
True or False: The '!' operator can be used to convert a truthy value to false.
True
156
What is the result of 'false && true'?
false
157
What does the '>>=' operator do?
It performs a right bitwise shift and assigns the result.
158
What is the output of '5 + (3 * 2)'?
11
159
What does the 'instanceof' operator return if the object is an instance of the constructor?
true
160
What is the output of '5 === '5''?
false
161
What is the result of '1 + 2 + 3 + 4 + 5'?
15
162
What does the '!' operator return for a truthy value?
false
163
What is the output of 'console.log(1 < 2 && 2 > 1)'?
true
164
What is the result of '10 - 5 * 2'?
0
165
What does the '=== ' operator check?
Strict equality.
166
What is the output of 'typeof {}'?
'object'
167
What is the result of '5 + 5 - 2 * 3'?
7
168
What does the '&&' operator return if the first operand is true?
The second operand
169
What is the output of 'console.log(5 == '5')'?
true
170
What is the result of '3 < 2'?
false
171
What does the 'in' operator return if the property exists?
true
172
What is the output of '5 / 2'?
2.5
173
What does the '>' operator check?
If the left operand is greater than the right operand.