js repeatify & no for loop
js repeatify
https://www.sitepoint.com/5-typical-javascript-interview-exercises/
padStart
String.prototype.repeatify = String.prototype.repeatify || function (times = 1) {
console.log(this)
// String {"abx"}
return [...``.padStart(times, ` `)].map((item, i) => item = this).join(``);
};
`abx`.repeatify(3);
// "abxabxabx"
arrow function bug
// ES6 无法改变 this 的指向
String.prototype.repeatify = (times = 1, that = this) => [...``.padStart(times, ` `)].map((item, i) => item = that).join(``);
`abx`.repeatify(3);
// "[object Window][object Window][object Window]"
Uint8Array
TypedArray bug
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!