我已经为Float32Array添加了3个名为'x','y'和'z'的属性。 getter在chrome和firefox都可以正常工作,但它似乎只能在chrome中使用。这是为什么?这是一个错误吗?有没有办法让它在Firefox中工作?Float32Array设置属性不能在Firefox中工作
Object.defineProperty(Float32Array.prototype, 'x', {
get: function(){
return this[0];
},
set: function(x){
this[0] = x;
}
});
// creating a Float32Array-Vector using mjs.js
var vector = V3.$(1,2,3);
// works fine
document.writeln(vector.x);
// works in chrome but not in firefox
vector.x = vector.y + vector.z;
感谢您的研究。我没有得到的是,我没有在对象或数组初始值设定项中设置属性,所以如果这真的不起作用? – Markus