compact()
功能
创建一个数组, 其中删除了所有 null 和 undefined 的值。
语法
langx.compact(array)
参数
- array
需删除空元素、undefined、null 的数组
范例
Example: langx.compact([1,,3,null,,5,,6,undefined,]),input 显示结果 1,3,5,6 。
<!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>
<input></input>
<script>
require(["skylark/finder", "skylark/langx", "skylark/datax"], function(finder, utils, datax) {
var text = langx.compact([1,,3,null,,5,,6,undefined,]);
datax.val(finder.find("input"),text)
});
</script>
</body>
</html>