1 测试方法
alert(exp) 输出到警告框
console.log(exp) 输出到控制台
document.write(exp) 输出到页面
2 数值的操作方法
parseInt(Number) 取整,没有副作用
parseFloat(Number) 强制转换为数字,没有副作用
Number.toFixed(保留的位数) 保留几位小数;注意:这个返回结果不再是Number类型而是字符串了。
3 向弹框输入内容的方法
var score = Number(prompt("请输入您的成绩"));
4 instanceof
变量 instanceof 对象------>布尔类型 判断这个变量是不是这个类型的
5其他类型转换为字符串
如果变量有意义调用.toString()使用转换
如果变量没有意义使用String()转换
6其他类型转换为布尔类型
console.log(Boolean(1));
console.log(Boolean(0));
console.log(Boolean(11));
console.log(Boolean(-10));
console.log(Boolean("哈哈"));
console.log(Boolean(""));
console.log(Boolean(null));
console.log(Boolean(undefined));
7typeof
typeof() 判断数据属于什么数据类型
8删除对象的属性
delete Object.属性名