1、返回数组中的最大最小值(参数是一组数,不是列表数组)
Math.max([value1[,value2, ...]])
Math.min([value1[,value2, ...]])
2、合并数组 Array.concat()返回值为创建新数组,需要赋值给变量进行使用,不会改变原有数组的值
3、函数多参数arguments转化为数组
var args = Array.prototype.slice.call(arguments); //通用方式,不应在 arguments 对象上使用 \
//slice 方法,这会阻碍 JavaScript 引擎的优化 (比如 V8 引擎)
var args = Array.slice(arguments); //如果 Array generics 可用的话
var args = Array.from(arguments); //推荐方式
4、常见html实体的字符替换
同理常见正则表达式的特殊字符链接:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Special_characters_in_regular_expressions
str = str.replace(/[&]/g,"&").replace(/[<]/g,"<").replace(/[>]/g,">")
.replace(/["]/g,'"').replace(/[']/g,"'");