Advertisement
NLinker

Comparison between class and function

Dec 13th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     class ChannelType {
  2.       constructor() { this.state = [] }
  3.       state() { return this.state }
  4.       take()  { this.state.push("take") }
  5.       put()   { this.state.push("put") }
  6.       flush() { this.state.push("flush") }
  7.       close() { this.state.push("close") }
  8.     }
  9.     const channel = new ChannelType()
  10.     // const channel = (function channel() {
  11.     //   let state = []
  12.     //   return {
  13.     //     state: state,
  14.     //     take: () => {state.push("take")},
  15.     //     put: () => {state.push("put")},
  16.     //     flush: () => {state.push("flush")},
  17.     //     close: () => {state.push("close")}
  18.     //   }
  19.     // })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement