首页 > IT职业 > IT职场 > js的基础内容,我会不断更新的
面向/基于对象
js数据类型包括原生数据类型和引用数据类型
原生数据
包括number String boolean undefined null
var price=1.6;//1.7
var money=2;
console.log(money-price);//舍入误差
//不可避免,只能近似四舍五入
console.log((money-price).toFixed(2));
console.log(555.555*100);//舍入误差 function String(x){
console.log("调用自己的String");
if(x===undefined){
//return 函数执行后,返回一个结果
return "undefined";
}else if(x==null){
return "null";
}else{
return x.toString();
}
}
console.log(
String(null),
String(undefined),
String(true),
String(12.5)
);
不加引号的true和false直接量,自动就是bool类型
判断对象的属性或数组的元素是否存在
包括Arry date Math function obj等 下一次接着补充
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2216/viewspace-2798075/ ,如需转载,请注明出处,否则将追究法律责任。