Utilities

  • fat arrow function syntax

  • template strings

Fat Arrow Functions

Fat arrow => functions are a shorthand notation for writing functions.

// ES5-like example
var data = ['Alice Green', 'Paul Pfifer', 'Louis Blakenship'];
data.forEach(function(line) { console.log(line); });

// Typescript example
var data: string[] = ['Alice Green', 'Paul Pfifer', 'Louis Blakenship'];
data.forEach( (line) => console.log(line) );

Template Strings

two important use...

  1. Variables within strings (without being forced to concatenate with +)

  2. Multi-line strings

Variables in strings

var firstName = "Nate";
var lastName = "Murray";

// interpolate a string
var greeting = `Hello ${firstName} ${lastName}`;

console.log(greeting);

Multiline strings

var template = `
<div>
 <h1>Hello</h1>
 <p>This is a great website</p>
</div>
`

Last updated

Was this helpful?