1
This commit is contained in:
28
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/forOf.js
Normal file
28
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/forOf.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var isArray = require('./isArray')
|
||||
var hasOwnProp = require('./hasOwnProp')
|
||||
|
||||
/**
|
||||
* 已废弃,被 some, every 替换
|
||||
* @deprecated
|
||||
*/
|
||||
function forOf (obj, iterate, context) {
|
||||
if (obj) {
|
||||
if (isArray(obj)) {
|
||||
for (var index = 0, len = obj.length; index < len; index++) {
|
||||
if (iterate.call(context, obj[index], index, obj) === false) {
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var key in obj) {
|
||||
if (hasOwnProp(obj, key)) {
|
||||
if (iterate.call(context, obj[key], key, obj) === false) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = forOf
|
||||
Reference in New Issue
Block a user