Demo entry 2840436

composition in ES6

   

Submitted by javier.arilos on Oct 08, 2015 at 21:37
Language: JavaScript. Code size: 262 Bytes.

const barker = (state) => ({
  bark: () => console.log('woof, woof' + state.name)
})

const angryHuman = (name) => {
  let state = {name};
  return Object.assign(
    {},
    barker(state)
  )
}

var angryJavi = angryHuman('javi')
angryJavi.bark()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).