MCPcopy Index your code
hub / github.com/ygs-code/vue / isValidArrayIndex

Function isValidArrayIndex

vue.js:103–109  ·  view source on GitHub ↗

* Check if val is a valid array index. * 检查VAL是否是有效的数组索引。

(val)

Source from the content-addressed store, hash-verified

101 * 检查VAL是否是有效的数组索引。
102 */
103 function isValidArrayIndex(val) {
104 //isFinite 检测是否是数据
105 //Math.floor 向下取整
106 var n = parseFloat(String(val));
107 //isFinite 如果 number 是有限数字(或可转换为有限数字),那么返回 true。否则,如果 number 是 NaN(非数字),或者是正、负无穷大的数,则返回 false。
108 return n >= 0 && Math.floor(n) === n && isFinite(val)
109 }
110
111 /**
112 * Convert a value to a string that is actually rendered.

Callers 2

setFunction · 0.85
delFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected