Font size
WorksheetsTypescript class 02
Total questions: 26
Worksheet time: 9mins
What does TypeScript add to JavaScript that makes it more robust?
Strongly-typed variables
Dynamic typing
Automatic memory management
Built-in debugging tools
What is the purpose of TypeScript's "Type Declaration"?
To define the types of data a variable can hold
To declare a new variable
To perform type casting
To add comments to the code
Typescript is
interpreted language
compiled language
What does TypeScript add to JavaScript to help catch errors at compile time?
Static typing
Dynamic typing
Runtime checks
Enhanced performance
In TypeScript, which keyword is used to declare a variable?
let
const
var
type
variable
Which of the following is used to indicate the type of a variable in TypeScript?
typeOf
isType
:
#
What tool can you use to transpile TypeScript code into JavaScript code?
TypeScript Compiler (tsc)
JavaScript Transformer (jst)
TypeScript Formatter (tsf)
JavaScript Linter (eslint)
Javascript is a subset of Typescript
True
False
JSON is
Used to store data
Used to transfer Data
File format
Used to maintain the version of packages
Used for Configuration setting
Our project is dependent on some packages (called as dependencies) and these packages are dependent on some other dependencies and those dependencies are further dependent on some other dependencies and so on these are called as
(a)
What is node module in our project?
store your all packages
all the dependencies are inside the node module
it manage the version of our project
it lock all the packages
None of above
What is the shortest program of javascript?
(a)
What is an output of this code?
const a = "Quiz 1"
a = "Quiz cancel"
a = "Quiz postponed"
console.log(a)
Quiz 1
Quiz cancel
Quiz postponed
Error
What is an output of this code?
let var1 = "Typescript Cheety"
var1 = "23"
console.log(var1)
Type Number is not assignable to Type string
23
Typescript Cheety
Error
Below code is in Typescript file and is an example of ?
let var1 = "Typescript Cheety"
var1 = "Python Cheety"
console.log(var1)
Type Inferance
Explicit Typing
Dynamic Typing
None of Above
The JSON object is written inside curly braces { }
True
False
JSON object is only used in javascript and typescript language.
True
False
JSON is similar to Javascript object.
True
False
As JSON is similar to javscript object so we can access it using dot notation
True
False
What is an output of this code?
let var1 : string = "Pakistani Developers "
let var2 : string = "are number "
let var3 : string = "1"
console.log(var1 + var2 + var3)
Number is not assignable to type string
Error: Strings cannot be added together
Pakistani Developers are number 1
None of above
What is an output of this code?
let var1 : string = "Welcome to programming"
var1 = 101
console.log(var1)
Welcome to programming
101
Welcome to programming 101
Type number is not assignable to type string
We can reassign value to a variable that initialize with const
True
False
We can reassign value to a variable that initialize with let
True
False
What is an output of this code in typescript file?
let var1;
var1 = "Welcome to typescript class"
var1 = 23
var1 = false
console.log(var1)
Welcome to typescript class
23
false
Error
What typescript compiler infer the datatype in below code
let value = null;
Unknown
void
any
undefined
null
What is an output of below code?
let value : null = 101;
console.log(value)
101
null
undefined
Error
