Property names inside classes get prefixed with the class name, even though they are not properties of that class.
input:
class Bad {
doOddBehaviour(obj) {
console.log(obj._prefixed + 1)
}
}
var myBad = new Bad()
myBad.doOddBehaviour({_prefixed: 5})
var myOk = {_prefixed: 5}
console.log(myOk._prefixed)
output (with --harmony option):
function Bad(){"use strict";}
Object.defineProperty(Bad.prototype,"doOddBehaviour",{writable:true,configurable:true,value:function(obj) {"use strict";
console.log(obj.$Bad_prefixed + 1) //notice that accessing the property of this object will fail (the output will be 'undefined')
}});
var myBad = new Bad()
myBad.doOddBehaviour({_prefixed: 5})
var myOk = {_prefixed: 5}
console.log(myOk._prefixed)
Property names inside classes get prefixed with the class name, even though they are not properties of that class.
input:
output (with --harmony option):
When executed, the console output will be:
Expected: