将一个数组中的所有元素转换到另一个数组中。
langx.map(elements, callback)
Example: 将原始数组中的每个值加 4 后,映射到新的数组中。
<!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> <span></span> <script> require(["skylark/finder", "skylark/langx", "skylark/datax"], function(finder, langx, datax) { arr = langx.map([0, 1, 2], function(n) { return n + 4; }); datax.text(finder.find("span"), arr.join(", ")); }); </script> </body> </html>