0
0
Typescriptprogramming~5 mins

String type behavior in Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the basic type used to represent text in TypeScript?
The string type is used to represent text in TypeScript. It holds sequences of characters.
Click to reveal answer
beginner
Are strings in TypeScript mutable or immutable?
Strings in TypeScript are immutable. Once created, their content cannot be changed directly.
Click to reveal answer
beginner
How can you create a multi-line string in TypeScript?
Use template literals with backticks (``) to create multi-line strings easily.
Click to reveal answer
beginner
What happens when you use the + operator with strings in TypeScript?
The + operator concatenates (joins) two or more strings into one string.
Click to reveal answer
intermediate
How does TypeScript handle string type checking?
TypeScript enforces that variables declared as string can only hold string values, helping catch errors at compile time.
Click to reveal answer
Which of the following is the correct way to declare a string variable in TypeScript?
Alet name: string = 'Alice';
Blet name = 123;
Clet name: number = 'Alice';
Dlet name: boolean = true;
What will the following code output? <br> let greeting = 'Hello';<br> greeting[0] = 'J';<br> console.log(greeting);
AJello
BError
CHello
Dundefined
How do you create a string that spans multiple lines in TypeScript?
AUsing double quotes with \n
BUsing backticks (template literals)
CUsing single quotes with \n
DUsing parentheses
What is the result of 'Hello' + ' ' + 'World' in TypeScript?
A'Hello World'
BError
C'Hello+World'
D'HelloWorld'
Which of these is NOT a string method in TypeScript?
Aincludes()
BtoUpperCase()
Cslice()
Dpush()
Explain how strings behave in TypeScript regarding mutability and concatenation.
Think about whether you can change a letter inside a string directly and how to combine strings.
You got /3 concepts.
    Describe how TypeScript helps ensure variables hold string values and what happens if you assign a different type.
    Consider what TypeScript does before running your code to catch mistakes.
    You got /3 concepts.