Math下的属性&方法
var vva = 1.2345678;
console.log(vva.toFixed(3));//进位,小数点后3位
console.log(vva.toPrecision(3));//进位
console.log(vva.toExponential(5));//科学计数法
console.log(vva.toString());
var uu1 = {
uu11: 112,
uu12: [12, 324, 34],
uu13: {oo: 1,o1:2},
uu14: function fcc() {
var b = {e:123,r:234};
return b;
},
uu15: {oo3: 34, oo1:23, oo2:[2,3,[23,34,34],34]}
};
console.log( 'uu11' in uu1); //判断的是下标
var ii = 1;
console.log(ii);
eval('ii = 2'); //将字符串变为程序语句
console.log(ii);
console.log(JSON.parse('{"uu11":112,"uu12":[12,324,34],"uu13":{"oo":1,"o1":2},"uu15":{"oo3":34,"oo1":23,"oo2":[2,3,[23,34,34],34]}}'));
console.log(JSON.stringify(uu1));
捕获可能出现的错误并且输出,不影响下方程序的进行
try{
var a88 = 0;
var b88 = 'df ';
var c88 = b88 / a88;
console.log(document.getElementById('body').innerHTML);
}catch (e){
console.log(e)
}
function Test() {
console.log(this instanceof Test);
if(typeof this === 'undefined'){ //typeof 任意一个变量 出来的都是字符串
throw TypeError("出错了,不能直接调用构造函数");
}
if(!(this instanceof Test)){ //两种方式
throw Error("出错!");
}
}
var test1 = new Test();//创建实例对象
Test(); //不是Test的实例对象