René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

prototype [JavaScript snippet]

function A(nm) {
  this.name = nm
//txt_out(this.s)
}
A.protoype.s = 'a:s'

//
//function B(qq) {
//  this.q = qq
//}

function main() {

//txt_out(A)
//txt_out(A.prototype)


  var a1 = new A('a1')
  var a2 = new A('a2')

  A.prototype.shared = 'shared by each instance of A'

  a1.unshared = 'only for a1'
  a2.mine     = 'only for a2'

  txt_out('a1')
  for (var k in a1) {
    txt_out('   ' + k + '=' + a1[k])
  }

  txt_out('a2')
  for (var k in a2) {
    txt_out('   ' + k + '=' + a2[k])
  }

}