2021
01-09
01-09
利用JS判断元素是否为数组的方法示例
此处提供可供验证的数据类型leta=[1,2,3,4,5,6];letb=[{name:'张飞',type:'tank'},{name:'关羽',type:'soldier'},{name:'刘备',type:'shooter'},];letc=123;letd='www';lete={name:'安琪拉',type:'mage'};1.通过Array.isArray()Array.isArray()能判断一个元素是否为数组,如果是就返回true,否则就返回falseconsole.log(Array.isArray(a));//trueconsole.log(Array.isArray(b));//trueco...
继续阅读 >