Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.rawgit.com/adriancmiranda/Proto/master/dist/Proto.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Proto v0.1.0 - Usage</title>
</head>
<body>
  <h1>Proto v0.1.0 - Usage</h1>
</body>
</html>
 
var Ninja = Proto.extends({
    // Objects doesn't affect implementations.
    options:{ ninjateste:'**' },
    kill:function(flush){
        console.log('kill '+ flush);
        if(flush) this.flush();
    }
});
var Human = Proto.extends({
    constructor:function(){
        console.log('i r human', this.$protoID);
        this.super();
    }
});
var ChuckNorris = Human.extends({
    options:{ skills:'ninja' },
    implements:[Ninja],
    constructor:function(){
        console.log('i r badass and.. ', this.$protoID);
        this.super();
        this.kill('with thumb');
    },
    rise:3
});
var Goku = ChuckNorris.extends({
    options:{ superpowers:['unknown'] },
    constructor:function(){
        console.log('Hello! I\'m goku and.. ', this.$protoID);
        this.super();
    },
    rise:function(){
        // override rise property
        // super returns rise property from superclass
        console.log('wait for', this.super(), 'days...');
        return this.super();
    }
});
var chuck = new ChuckNorris();
chuck.kill('again!');
console.log('chuck:', chuck instanceof Proto); // true
console.log('chuck:', chuck instanceof Ninja); // false
console.log('chuck:', chuck instanceof Human); // true
console.log('chuck:', chuck instanceof ChuckNorris); // true
console.log('chuck.options:', chuck.options);
console.log('chuck:', chuck);
var goku = new Goku();
goku.rise();
console.log('goku:', goku);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
adriancmirandapro
0viewers