Skip to content

Instantly share code, notes, and snippets.

View brauliodiez's full-sized avatar

Braulio Diez brauliodiez

View GitHub Profile
@brauliodiez
brauliodiez / readme.md
Created June 4, 2017 09:12
javascript currying

Currying

Currying is the act of turning a function into a new function that takes slightly fewer arguments, achieving a slightly more specific task.

http://macr.ae/article/es6-and-currying.html

Steps

Let's start by making a simple function that will sum up two numbers, using currying:

@brauliodiez
brauliodiez / readme.md
Last active June 20, 2017 10:06
ES6 Fat arrow, solving the 'this' problem
@brauliodiez
brauliodiez / readme.md
Created June 4, 2017 09:11
Simple Destructuring sample
@brauliodiez
brauliodiez / readme.md
Last active June 4, 2018 10:01
Simple ES6 reduce sample

reduce

Reduce allows us calculate a total, applying an operation on every operation of an array.

This can save us lot of "for" loops (enhannce readibility).

steps

Let's implement a function that will sum up an array.

@brauliodiez
brauliodiez / readme.md
Created June 4, 2017 09:10
javascript var vs const vs let
@brauliodiez
brauliodiez / readme.md
Created June 4, 2017 09:09
SImple ES6 backticks usage

Backticks

Just using the new ES6 backticks to:

  • Display multiline text.
  • Embed variable values into strings (similar to print.format or c# string.format).

Steps

  • Let's first create a multiline text using an ES6 approach:
@brauliodiez
brauliodiez / readme.md
Created June 4, 2017 09:07
Simple ES6 'map' sample

map

Map allows us to apply an operation to each item of an array, returning a new array that contains the items with the operation applied.

This can save us lot of "for" loops (enhannce readibility).

steps

Let's implement a function that will apply a discount all the elements of a given array.