Junior-Level TypeScript Exam Review

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/10

flashcard set

Earn XP

Description and Tags

These flashcards cover key concepts, definitions, and example code related to TypeScript as reviewed in the junior-level exam notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

11 Terms

1
New cards

What is the default type of a variable in TypeScript if no type is assigned?

any

2
New cards

What does the as keyword do in TypeScript?

Casts a value to a specific type.

3
New cards

What is the difference between let and const in TypeScript?

let is for variables that can be changed and are in a local scope, while const is for variables that can't be changed.

4
New cards

What will be the output of the code in question 4?

"five".

5
New cards

How do you define a function that does not return anything?

function logMessage(): void { console.log("Hello"); }

6
New cards

What does ? mean in a function parameter?

It marks the parameter as optional.

7
New cards

How do you create a tuple type in TypeScript?

let myTuple: [string, number] = ["hello", 10];

8
New cards

What is the difference between unknown and any?

unknown is for a variable of which the type is not known, while any can be reassigned to any possible type.

9
New cards

What will happen if you try to reassign a readonly property?

It will throw a compilation error.

10
New cards

What does 'typeof do in TypeScript?

Returns the JavaScript runtime type of a variable.

11
New cards