This quiz will cover all the introductory level questions for typescript.
Question 1
What is the primary purpose of TypeScript?
To replace JavaScript completely
To add static typing and enhance JavaScript features
To make JavaScript code run faster
To compile directly into machine code
Question 2
How do you explicitly declare a variable with a type in TypeScript?
let name = "Alice"
let name: string = "Alice"
let string name = "Alice"
string name = "Alice"
Question 3
. Which of the following is true about TypeScript?
TypeScript code runs directly in the browser
TypeScript must be compiled into JavaScript
TypeScript does not support JavaScript features
TypeScript cannot be used in frontend development
Question 4
What command is used to install TypeScript globally using npm?
npm install typescript
npm install -g typescript
install -g typescript
npm typescript install
Question 6
How do you compile a TypeScript file named script.ts?
tsc script.ts
node script.ts
compile script.ts
typescript script.ts
Question 7
Which of the following is NOT a valid TypeScript type?
number
boolean
character
unknown
Question 8
What will be the output of the following TypeScript code?
let x: any = "Hello";
x = 10;
console.log(typeof x);
"string"
"number"
"any"
"undefined"
Question 9
Which TypeScript feature allows defining a custom structure for objects?
Classes
Interfaces
Functions
Enums
Question 10
Prevents a variable from being modified after initialization
Makes a variable accessible only within a function
Prevents a variable from being used
Allows reassignment of a variable
There are 10 questions to complete.