(obj, fn)
| 48 | } |
| 49 | |
| 50 | function forEach (obj, fn) { |
| 51 | if (obj === null || typeof obj === 'undefined') { |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | if (typeof obj !== 'object') { |
| 56 | obj = [obj] |
| 57 | } |
| 58 | |
| 59 | if (isArray(obj)) { |
| 60 | for (let i = 0, l = obj.length; i < l; i++) { |
| 61 | fn(obj[i], i, obj) |
| 62 | } |
| 63 | } else { |
| 64 | for (const key in obj) { |
| 65 | if (Object.prototype.hasOwnProperty.call(obj, key)) { |
| 66 | fn(obj[key], key, obj) |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | function isNumberStr (str) { |
| 73 | return /^\d+$/.test(str) |