Make primivive[].clone() work in older browsers and in Rhino

This commit is contained in:
Alexey Andreev 2017-11-05 12:29:02 +03:00
parent 840b9dfe8b
commit 6817618b4e

View File

@ -140,6 +140,15 @@ function $rt_arraycls(cls) {
return str;
};
$rt_setCloneMethod(arraycls.prototype, function () {
var dataCopy;
if ('slice' in this.data) {
dataCopy = this.data.slice();
} else {
dataCopy = new this.data.constructor(this.data.length);
for (var i = 0; i < dataCopy.length; ++i) {
dataCopy[i] = this.data[i];
}
}
return new arraycls(this.data.slice());
});
var name = "[" + cls.$meta.binaryName;