Font size
WorksheetsTypescript Basics
Total questions: 20
Worksheet time: 10mins
How would you describe Typescript as a programming language?
Strongly Typed
Weakly Typed
Dynamically Typed
Statistically Typed
Which file extension is commonly used for TypeScript files?
.js
.tx
.ts
.tys
TypeScript code is ultimately compiled into which language?
C++
Java
Python
JavaScript
What command correctly represents build/compiling Typescript to JavaScript
build
tsc
node tsc
build tsc
const student = 'Usman';
The implicit type here is a?
Number
String
Boolean
Object
Which of the following correctly define an explicit type?
let a = true
let a: boolean = true
let a = true:bolean
let boolan: a = true
At what time does checks in Typescripts occur?
Run time
Compile time
Code time
Dev Time
Rasheed wants to create an array of only strings, which syntax should he use?
names = [ ]
names: any = [ ]
names: string = [ ]
names: string[] = [ ]
Using this function:
const addNum = (num1: number, num2: number, num4?:number, num3: number = 10) => {}
num3 represents?
Optional parameters
Default parameters
Return type
None of the options
Using this function:
const addNum = (num1: number, num2: number, num4?:number, num3: number = 10) => {}
num4 represents?
Optional parameters
Default parameters
Return type
None of the options
Ella is creating a function to integrate data service providers(mtn, glo, etc). Which of the following concepts can help her define the different providers in her function
Type alias
Switch parameters
Optional parameters
Generics
Which of the following is used to create a union type in TypeScript?
&
|
~
^
What is the purpose of the "unknown" data type in TypeScript?
Represents a variable that can have any type
Represents a function that never returns
Represents an object with an unknown structure
There is no unkonwn
How can you declare a generic type in TypeScript?
Using the "generic" keyword
Using the "type" keyword
Using the "<>" syntax
Using the "any" keyword
A class can implement an interface
True
False
How na??
None of the options
const createPerson = <T>(person: T) => ...
Which of the following is a correct way to use the above function
createPerson('sam')
createPerson(true)
createPerson({
name: 'sam'
})
All of the options
enum Color {
Red,
Green,
Blue,
}
What is the value of blue?
0
1
2
3
let x: [string, number];
What does this represent?
Any Type
Union Type
Tuples
Array Type
Which of the following is not an access modifier
Public
Private
Protected
Readonly
Static
What is the purpose of the "typeof" operator in TypeScript?
To check the type of a variable
To define a new variable
To create an instance of an object
To import external modules
