//基本类型与引用类型也就是栈内存还是堆内存,栈快而小,堆大而需要引用索引
//数字、字符串、数组、对象、函数的定义
var a = 27.50;
var b = 'hello world';
var c = [];
var d = {};
var e = function(){};
//数字
a.toFixed(4); //27.5000 非常好用的格式化方法
//字符串
b.substr(6); //world
b.replace('o','m'); //hellm world
b.replace(/o/ig,'m'); //hellm wmrld
b.indexOf('o'); //4
function allIndexOf(Str,str){
var a = [];
var index = Str.indexOf(str);
while(index > -1){
a.push(index);
index = Str.indexOf(str,pos + 1);
}
return a;}
allIndexOf(b,'o'); //[4,7]
//Math内置对象
function random(start,end){
var total = end - start + 1;
return Math.floor(Math.random()*total + start);
}
random(3,8); //3到8之间的随机数
Math.round(2.5); //3
Math.ceil(2.1); //3
Math.floor(2.8); //2