Im Flash
Im Flash

Reputation: 45

Typescript Function Declaration, style difference

I started to use Typescript and i don't get what differences in these method declarations are:

onSave(){ /*method body*/ }
public onSave = () => { /*method body*/ }

Also, What I am supposed to search on Google or StackOverflow to find more about this topic?

Thank you,

(Sorry for the long post :D)

Upvotes: 0

Views: 203

Answers (1)

anteAdamovic
anteAdamovic

Reputation: 1468

You are referring to regular functions and arrow function, they're explained in detail in TypeScript docs: http://www.typescriptlang.org/docs/handbook/functions.html

The general difference between a regular function and arrow function is that regular function operates within it's own scope (this) while arrow function remains in the scope of the parent.

Upvotes: 1

Related Questions