Typescript Flashcards

(26 cards)

1
Q

Vad ärTypeScript?

A

TypeScript ett superset till JavaScript som lägger till statisk typning.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: TypeScript can be used to write both client-side and server-side applications.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Fill in the blank: In TypeScript, the keyword ______ is used to declare a variable.

A

let

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of the ‘interface’ keyword in TypeScript?

A

To define the shape of an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What symbol is used to denote a type annotation in TypeScript?

A

:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following is a valid TypeScript type? (a) number (b) string (c) boolean (d) All of the above

A

d) All of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the ‘any’ type in TypeScript signify?

A

It allows a variable to hold any type of value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the ‘enum’ keyword in TypeScript?

A

To define a set of named constants.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or False: TypeScript supports generics.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the syntax for creating a function in TypeScript that takes a number and returns a string?

A

function example(num: number): string { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Fill in the blank: TypeScript files typically have the file extension ______.

A

.ts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the default visibility of a class member in TypeScript?

A

public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which keyword is used to create a class in TypeScript?

A

class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a tuple in TypeScript?

A

An array with a fixed number of elements with known types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

True or False: TypeScript does not allow for optional parameters in functions.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What operator is used for type assertion in TypeScript?

17
Q

What is the purpose of the ‘readonly’ modifier in TypeScript?

A

To indicate that a property cannot be modified.

18
Q

Fill in the blank: The ______ keyword is used to inherit from a base class in TypeScript.

19
Q

What is the purpose of the ‘namespace’ keyword in TypeScript?

A

To organize code and avoid naming conflicts.

20
Q

Which of the following is NOT a primitive type in TypeScript? (a) number (b) string (c) object (d) boolean

21
Q

What keyword is used to define an abstract class in TypeScript?

22
Q

True or False: TypeScript can infer types automatically.

23
Q

What is a union type in TypeScript?

A

A type that can be one of several types.

24
Q

What is the use of the ‘import’ statement in TypeScript?

A

To include modules and dependencies.

25
Fill in the blank: The ______ keyword is used to create an interface in TypeScript.
interface
26
What is the function of the 'this' keyword in TypeScript?
To refer to the current instance of a class.