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: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.

@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:10
javascript var vs const vs let
@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:11
Simple Destructuring sample
@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: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 April 15, 2018 07:02
Spread Operator simple samples

spread operator

The spread syntax allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) or multiple variables (for destructuring assignment) are expected.

steps

Copying an object but replacing some properties:

This one we will need bable to make it work

@brauliodiez
brauliodiez / readme.md
Last active October 1, 2017 12:15
Very basic intro, typescript types

Typescript getting started

Let's get started with Typescript.

We will use Typescript online playground for this demos:

http://www.typescriptlang.org/play/

Steps

  • Let's start with something very basic, if we paste this code on codepen (javascript):
@brauliodiez
brauliodiez / readme.md
Last active June 4, 2017 09:17
Typescript, playing a bit with types

Start

For sure now you will have a lot of questions poping up into your head, about cases where typing has not to be strict.

We will continue using typescript playground.

Let's start diving into that.

Topics to cover: