This quiz will cover topics related to Variables & Data Types in TypeScript
Question 1
Which data type is used to represent a list of values in TypeScript?
array
object
list
array[]
Question 2
Which of the following is not a valid data type in TypeScript?
boolean
string
integer
any
Question 3
Which data type is used to represent a sequence of characters in TypeScript?
string
char
text
character
Question 4
Which TypeScript data type is used to represent a collection of key-value pairs?
Object
Array
Set
Map
Question 5
What type is returned by a function that has no return statement?
null
undefined
void
any
Question 6
What does the never
type represents in TypeScript?
It represents an object that never changes.
It represents a value that never exists.
It represents a function that always throws an error or never finishes.
It represents a type with a specific default value.
Question 7
Which type is used to define an object with properties in TypeScript?
Object
interface
type
array
Question 8
How can you declare a variable of type string
or number
in TypeScript?
let value: string | number;
let value: string & number;
let value: any;
let value: union<string, number>;
Question 9
What is the type of a variable that has been declared as let x = null;
?
null
undefined
any
object
Question 10
What does the unknown
type represents in TypeScript?
It is a type that can hold any value, similar to any
, but requires type checking before performing operations on it.
It represents a value that is always undefined
.
It represents a variable whose value can never be determined.
It is the same as any
but allows no type inference.
There are 10 questions to complete.