Skip to content

Constructor

Ben Christel edited this page Dec 22, 2020 · 1 revision

A constructor is a Nilpotent, non-ReferentiallyTransparent Routine that returns an Object.

Example:

function Counter() {
  let count = 0
  return {increment, decrement, value}
  
  function increment() {
    count++
  }

  function decrement() {
    count--
  }

  function value() {
    return count
  }
}
Clone this wiki locally