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 發佈文章使用:只允許註冊用戶纔可以訪問!