Typescript at LMU München

Flashcards and summaries for Typescript at the LMU München

Arrow Arrow

It’s completely free

studysmarter schule studium
d

4.5 /5

studysmarter schule studium
d

4.8 /5

studysmarter schule studium
d

4.5 /5

studysmarter schule studium
d

4.8 /5

Study with flashcards and summaries for the course Typescript at the LMU München

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What are the types in Typescript?

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What is Type inference in Typescript?

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What is the "read-only" property?

This was only a preview of our StudySmarter flashcards.
Flascard Icon Flascard Icon

Millions of flashcards created by students

Flascard Icon Flascard Icon

Create your own flashcards as quick as possible

Flascard Icon Flascard Icon

Learning-Assistant with spaced repetition algorithm

Sign up for free!

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What is an abstract class?

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

How to implement the Singleton pattern?

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

1. What are Type Guards?

2. What are discriminated unions?

3. What is type casting?

4. What is "!"?

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What are index properties?

This was only a preview of our StudySmarter flashcards.
Flascard Icon Flascard Icon

Millions of flashcards created by students

Flascard Icon Flascard Icon

Create your own flashcards as quick as possible

Flascard Icon Flascard Icon

Learning-Assistant with spaced repetition algorithm

Sign up for free!

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What is a function overload?

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What is optional chaining?

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What is nullish coalescing?

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

When to use static methods and properties?

This was only a preview of our StudySmarter flashcards.
Flascard Icon Flascard Icon

Millions of flashcards created by students

Flascard Icon Flascard Icon

Create your own flashcards as quick as possible

Flascard Icon Flascard Icon

Learning-Assistant with spaced repetition algorithm

Sign up for free!

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

What is Encapsulation?

Your peers in the course Typescript at the LMU München create and share summaries, flashcards, study plans and other learning materials with the intelligent StudySmarter learning app.

Get started now!

Flashcard Flashcard

Exemplary flashcards for Typescript at the LMU München on StudySmarter:

Typescript

What are the types in Typescript?

Note: all types in TS are lowercase


1) number

2) string

3) boolean

4) object (key types can be added)

e.g. const person = {

   name: string;

   age: number;

} = {

   name: "Max",

   age: 23

}

5) Array (e.g. string[])

6) Tuple (e.g. [number, string])

Attention: push() works also with 1 element only

7) enum 

e.g. enum Role { ADMIN, READ_ONLY, AUTHOR }

8) any (e.g. any[] or any) <-- to avoid!!!

9) union (e.g. string | number)

Note: additional runtime type checking might be necessary

10) literal (e.g. 'as-string' | 'as-number') with union

11) custom type/type alias (e.g.

  1. type User = { name: string; age: number };

)

12) function return type (e.g. function add(n1: number, n2: number): number) & void

Note: a functions type should be void not undefined when it returns nothing

13) Function (e.g. let func = add: Function) & function types (e.g. let func = add: (a: number, b: number) => number (2 params, returns 1 number))

14) callback type (e.g. cb: (num: number => void) where void tells that we are not interested in a return value)

15) unknown (better than any)

16) never (e.g. when a function never returns)

17) Intersection Type & (to combine 2 types or interfaces)

Typescript

What is Type inference in Typescript?

Example:

const age = 28;


Typescript infers/assumes that this age is constant and uses number. So you don't need to explicitly add a type (like const age:number = 28).

Type inference also happens for functions

Typescript

What is the "read-only" property?

e.g.

constructor(private read-only id: string) {

  this.id = id

}

Typescript

What is an abstract class?

a class which is abstract and has abstract functions. It forces child classes to implement the abstract functions. It cannot be instantiated but has to be extended by a child class

Typescript

How to implement the Singleton pattern?

With a private constructor and a static method which either returns an instance or creates a new instance if no instance is declared yet.

Typescript

1. What are Type Guards?

2. What are discriminated unions?

3. What is type casting?

4. What is "!"?

1. To check the type during run-time, as multiple types are in play


  • typeof
  • instanceof
  • in


Note: type guards don't work with interfaces as they are not compiled to JS


2. every interface has a  type prop. In a function define a switch statement to catch the types.


3. 2 possibilities:

a) <typesomething>document.getElementById('.id');

b) document.getElementById('.id') as typesomething;


4. If you are sure that an expression will not be null

document.getElementById('.id')!

Typescript

What are index properties?

when you don't know yet what properties (and how many) an interface will have

e.g. [prop: string]: string


Note: it restricts the type to only use the index properties type (here string)

Typescript

What is a function overload?

when a function has several function definitions with different types

Typescript

What is optional chaining?

? operator checks if value is undefined (see ruby)

Typescript

What is nullish coalescing?

?? operator, to capture undefined & null

e.g. const var = variable ?? "something";


falls back to something


Note: empty string falls to variable

Typescript

When to use static methods and properties?

When you want to create a utility (such as Math.x) or don't need an instance of the class

Typescript

What is Encapsulation?

metaphor: pill

Encapsulation means bundling properties and methods in a class to shield them from the outside (information hiding) . The hidden parts are only accessible through getters and setters. 

e.g. a class that holds variables and methods


Sign up for free to see all flashcards and summaries for Typescript at the LMU München

Singup Image Singup Image
Wave

Other courses from your degree program

For your degree program Typescript at the LMU München there are already many courses on StudySmarter, waiting for you to join them. Get access to flashcards, summaries, and much more.

Back to LMU München overview page

javascript

Verlagstypen

Typografie Schrift anwenden

4. Types of business organizations

What is StudySmarter?

What is StudySmarter?

StudySmarter is an intelligent learning tool for students. With StudySmarter you can easily and efficiently create flashcards, summaries, mind maps, study plans and more. Create your own flashcards e.g. for Typescript at the LMU München or access thousands of learning materials created by your fellow students. Whether at your own university or at other universities. Hundreds of thousands of students use StudySmarter to efficiently prepare for their exams. Available on the Web, Android & iOS. It’s completely free.

Awards

Best EdTech Startup in Europe

Awards
Awards

EUROPEAN YOUTH AWARD IN SMART LEARNING

Awards
Awards

BEST EDTECH STARTUP IN GERMANY

Awards
Awards

Best EdTech Startup in Europe

Awards
Awards

EUROPEAN YOUTH AWARD IN SMART LEARNING

Awards
Awards

BEST EDTECH STARTUP IN GERMANY

Awards
X

StudySmarter - The study app for students

StudySmarter

4.5 Stars 1100 Rating
Start now!
X

Good grades at university? No problem with StudySmarter!

89% of StudySmarter users achieve better grades at university.

50 Mio Flashcards & Summaries
Create your own content with Smart Tools
Individual Learning-Plan

Learn with over 1 million users on StudySmarter.

Already registered? Just go to Login