This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 策略对象 | |
const strategies = { | |
isNonEmpty(value, errorMsg) { | |
return value === '' ? | |
errorMsg : void 0 | |
}, | |
minLength(value, length, errorMsg) { | |
return value.length < length ? | |
errorMsg : void 0 | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arrLike = { | |
length: 4, | |
2: "foo" | |
}; | |
Array.from(arrLike); // [undefined, undefined, "foo", undefined] , length 是类数组对象必须的属性 | |
// Array.from还可以接受一个映射函数作为第二个参数类似Array.map(..) | |
var arrLike = { | |
length: 4, | |
2: "foo" |