19

I saw in a javascript code written by a young guy this function

function foo(e:MouseEvent){
   ...
}

I want to know what does e:MouseEvent do?

Mariksel Azemaj
  • 530
  • 7
  • 18

1 Answers1

23

'e:MouseEvent' is a named parameter with a type declaration in typescript. A colon is used in typescript parameters to bind a parameter to a specific type which, in this case, is type 'MouseEvent'.

e is often used as the parameter name for a javascript event. Given the type it's likely a function that responds to a click event.

You can read more details about the syntax for it under the 'Function Types' heading of TypeScript's official documentation: https://www.typescriptlang.org/docs/handbook/functions.html.

Christopher Bradshaw
  • 2,615
  • 4
  • 24
  • 38