/Math工具函数/
//1、π
consle.log(Math.PI)
//2、随机random()---> [0, 1)
consle.log(Math.random())
//3、向下取整,Math.floor()
//4、三角函数,反三角函数
Math.sin()
Math.asin()
Math.cos()
Math.acos()
Math.tan()
Math.atan()
//5、角度、弧度互换
//6、返回一个坐标对应的角度
Math.atan2() -------->(PI, PI]
//7、开根
Math.sqrt()
/数组的高级使用/
//1、array.length,获取数组的长度
//2、遍历一个数组
for(var key in array_num) { //in用于,数组或表
console.log(key + ":-->" + array_num[key];
}
//3、数组末尾加入一个元素push
array_num.push();
//4、查找对象,在数组中对应的索引indexOf
array_num.indexOf();
//5、删除数组的某个元素splice(索引, 删除个数)
//6、数组的排序,快速排序
//sort函数,要自己定义一个比较函数
array_num.sort(function(lhs, rhs) {
if (lhs < rhs) {return -1;} //-1,lhs排rhs左边,升序格式
else if(lhs > rhs) {return 1;} //1, 排右边
else {return 0;} //相等,不改变
});
array_num.sort(function(a, b) {
return a-b; //升序排列,b-a是降序
})
//7、随机打乱一个数列
array_num.sort(function(a, b) {
if (Math.random() < 0.5) {
return -1;
}
else {
return 1;
}
})
//调用array_num[0],则可以实现,从数组中随机抽出一个
/字符串高级使用/
//1、str.length
//2、str.indexOf()返回子串,首次出现的位置
//3、str.replace("aa", "bb");替换,重新生成字符串对象!!!
//4、toLowerCase变小写, toUpperCase变大写
/遍历/
//1、遍历一个表,for(key in table)
//2、删除一个表,
delete array["aa"];