0

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)

Im Flash
  • 45
  • 1
  • 8
  • see this [link](https://basarat.gitbooks.io/typescript/docs/arrow-functions.html) or [this](https://codecraft.tv/courses/angular/es6-typescript/arrow/) – Fateme Fazli Apr 04 '18 at 09:04
  • Maybe this link helps: https://stackoverflow.com/questions/47433652/different-ways-to-define-a-method-in-typescript/47434165#47434165 – Titian Cernicova-Dragomir Apr 04 '18 at 09:06
  • Thank you all for the support! I marked my question as duplicate. I apologize, but i didn't know what to look for – Im Flash Apr 05 '18 at 10:19

1 Answers1

1

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.

anteAdamovic
  • 1,462
  • 12
  • 23