SOURCE

function assert(value, text) {
  if(value === true) {
    console.log(text)
  } else {
    console.log('error')
  }
}
function Ninja() {
  var feints = 0
  this.getFeints = function() {
    return feints
  }
  this.feint = function() {
    feints++
  }
}

var ninja1 = new Ninja()
assert(ninja1.feints === undefined,"and the  private data is inaccessible to us")

ninja1.feint()

assert(ninja1.getFeints() === 1, "we are able to access the internal feint count")

var ninja2 = new Ninja()
assert(ninja2.getFeints() === 0,"the second ninja object get its own feints variable")


























console 命令行工具 X clear

                    
>
console