转换一个类似数组的对象成为真正的JavaScript数组。
langx.makeArray(obj, offset, startWith)
Example: 将一个 HTMLElements 集合转换成对应的数组。判断是否转成数组,input 显示判断值。
<!DOCTYPE html> <html> <head> <style> </style> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script> <script> require.config({ baseUrl: "./", packages: [{ name: "skylark", location: "../../../src/skylark" }, ] }); </script> </head> <body> <div>First</div> <div>Second</div> <div>Third</div> <div>Fourth</div> Is a array? <input></input> <script> require(["skylark/query", "skylark/finder", "skylark/langx", "skylark/datax"], function(query, finder, langx, datax) { var elems = document.getElementsByTagName("div"); // returns a nodeList var arr = langx.makeArray(elems); arr.reverse(); // use an Array method on list of dom elements query(arr).appendTo(document.body); var text = langx.isArray(arr); datax.val(finder.find("input"), text) }); </script> </body> </html>