-1

I'm new to Javascript and I want to know what is the below pattern of code called.

GetDatasetProtocols: workbookId => `${API_QUERY_SVC_URL}dataset/protocols/${workbookId}`
Shousha
  • 43
  • 2
  • 10
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals – Teemu Apr 04 '18 at 11:00
  • 1
    arrow functions. – haku Apr 04 '18 at 11:01

2 Answers2

1

That is an arrow function. The most important difference of an arrow function compared to a "regular" function is that the this keyword within an arrow function des not refer to the object the function is called from, but to the scope where the function is defined.

Arrow functions have been introduced in ES6. You can use them in TypeScript also when you target earlier JS versions. TypeScript will produce code that emulates the scope of this in the arrow function.

Sefe
  • 13,731
  • 5
  • 42
  • 55
0

Besides arrow functions, you also have template literals here: ${API_QUERY_SVC_URL}dataset/protocols/${workbookId}

Check documentation here

Damian Peralta
  • 1,846
  • 7
  • 11