Vad ärTypeScript?
TypeScript ett superset till JavaScript som lägger till statisk typning.
True or False: TypeScript can be used to write both client-side and server-side applications.
True
Fill in the blank: In TypeScript, the keyword ______ is used to declare a variable.
let
What is the purpose of the ‘interface’ keyword in TypeScript?
To define the shape of an object.
What symbol is used to denote a type annotation in TypeScript?
:
Which of the following is a valid TypeScript type? (a) number (b) string (c) boolean (d) All of the above
d) All of the above
What does the ‘any’ type in TypeScript signify?
It allows a variable to hold any type of value.
What is the purpose of the ‘enum’ keyword in TypeScript?
To define a set of named constants.
True or False: TypeScript supports generics.
True
What is the syntax for creating a function in TypeScript that takes a number and returns a string?
function example(num: number): string { }
Fill in the blank: TypeScript files typically have the file extension ______.
.ts
What is the default visibility of a class member in TypeScript?
public
Which keyword is used to create a class in TypeScript?
class
What is a tuple in TypeScript?
An array with a fixed number of elements with known types.
True or False: TypeScript does not allow for optional parameters in functions.
False
What operator is used for type assertion in TypeScript?
as
What is the purpose of the ‘readonly’ modifier in TypeScript?
To indicate that a property cannot be modified.
Fill in the blank: The ______ keyword is used to inherit from a base class in TypeScript.
extends
What is the purpose of the ‘namespace’ keyword in TypeScript?
To organize code and avoid naming conflicts.
Which of the following is NOT a primitive type in TypeScript? (a) number (b) string (c) object (d) boolean
c) object
What keyword is used to define an abstract class in TypeScript?
abstract
True or False: TypeScript can infer types automatically.
True
What is a union type in TypeScript?
A type that can be one of several types.
What is the use of the ‘import’ statement in TypeScript?
To include modules and dependencies.