slice和Array.form方法,具体见示例代码:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<title>值和类型</title>
</head>
<body>
<script type="text/javascript">
function foo() {
//方法一:使用slice。apply和call均可,扩充运行的作用域
var arr = Array.prototype.slice.apply(arguments);
arr.push(‘last‘);
console.log(arr);
}
foo(‘a‘, ‘b‘);
var s = ‘mfg‘;
//方法二:使用ES6的Array.from方法
console.log(Array.from(s));
</script>
</body>
</html>