标签:link 参数 文本 ons color resources 返回 resource cti
Ext.isIterable用于判断传入的参数是否为可迭代的
在这4种情况下,函数返回true
1:数组
2:函数参数arguments
3:HTML collections : NodeList
4:HTML collections : HTMLCollection
测试代码如下:
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 2 "http://www.w3.org/TR/html4/loose.dtd"> 3 <html> 4 <head> 5 <meta charset="UTF-8"> 6 <title>Ext.iterable</title> 7 <link rel="stylesheet" type="text/css" href="js/ext4/resources/css/ext-all.css"> 8 <link rel="stylesheet" type="text/css" href="css/icon.css"> 9 <!--<script type="text/javascript" src="js/ext4/bootstrap.js"></script>--> 10 <script type="text/javascript" src="js/ext4/ext-all-debug.js"></script> 11 12 <script type="text/javascript" src="js/ext4/locale/ext-lang-zh_CN.js"></script> 13 <script type="text/javascript"> 14 Ext.onReady(_pageLoaded); 15 16 /** 17 * 页面加载完毕后执行的函数 18 * @private 19 */ 20 function _pageLoaded(){ 21 var arr = [1,2,3]; 22 console.info("arr:%o",arr); 23 console.info(Ext.isIterable(arr)); //数组 24 25 add(2,3); 26 27 var tableNode = document.getElementById(‘table1‘); 28 29 var childNodes = tableNode.childNodes; 30 console.info(‘表格的子节点:%o‘,childNodes); 31 console.info(Ext.isIterable(childNodes));//NodeList 32 33 var children = tableNode.children; 34 console.info("表格的子元素:%o",children); 35 console.info(Ext.isIterable(children));//HTMLCollection 36 37 var obj ={}; 38 obj.length=3; 39 obj[‘0‘]=12; 40 obj[‘1‘]=34; 41 obj[‘2‘]=56; 42 console.info("obj:%o",obj); 43 var bool = Ext.isIterable(obj); 44 console.info(bool); 45 46 } 47 48 function add(x,y){ 49 console.info("arguments:%o",arguments); 50 console.info(Ext.isIterable(arguments));//函数参数 51 return x+y; 52 } 53 54 </script> 55 </head> 56 <body> 57 <table id="table1"> 58 <tr> 59 <td>1</td> 60 <td>2</td> 61 </tr> 62 <tr> 63 <td>3</td> 64 <td>4</td> 65 </tr> 66 </table> 67 <span id="node1">测试文本~~~</span> 68 <span id="node2"> </span> 69 </body> 70 </html>
标签:link 参数 文本 ons color resources 返回 resource cti
原文地址:https://www.cnblogs.com/thaipine/p/10750875.html