Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<body>
<script>
var vals = {
    _y : 0,
    z : 0,
    set y(val) {
        this._y = val;
    },
    get y() {
        this.z = this._y + 1
        return this._y;
    } 
}
vals.y = 6;
vals.z = 1 + vals.y;
</script>
<button onclick="vals.y++">Increment</button>
<button onclick="alert(vals.y)">What is y?</button>
<button onclick="alert(vals.z)">What is z?</button>
</body>
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers