2019-02-14js类型
作者:
空天啸鹤 | 来源:发表于
2019-02-15 00:49 被阅读0次s.len = 5;
console.log(s.len)
// 包装类型不能写属性
undefined
// 值类型和包装类型type 区别
typeof s
"string"
var S= new String('ggg');
typeof S
"object"
var a = null;
var b = 0;
console.log(a ==b)
false
var a = null;
var b = 0;
console.log(Number(a) ==b)
true
undefined == null
true
0 == null
false
0 == false
true
null == false
false
Object(null)
{}
Object(null) == null
false
Object(undefined)
{}
(0.12340).toFixed(2)
"0.12"
(0.12340).toExponential()
"1.234e-1"
(0.12340).toPrecision(2)
"0.12"
(1.12340).toPrecision(2)
"1.1"
(1.12340).toPrecision(10)
"1.123400000"
(0.12340).toExponential(2)
"1.23e-1"
parseInt(' 123--gosdof')
123
parseFloat(' 22.0 .234--g')
22
if(new Boolean(false)) console.log("gogoog")
VM1000:1 gogoog
toString()
valueOf() 默认对象本身
转String ,先toSting 看是否原始值,再看valueOf;再异常
转Number,先看valueOf,再toString;再异常
日期,先valueOf,直接使用。
=,>, < 比较运算符转换类型后后,得到原始值不会再进一步转换成数字或字符;
但 +,==,!= 不一样;
日期类型,+转string , - 转字符, >转数字;
本文标题:2019-02-14js类型
本文链接:https://www.haomeiwen.com/subject/adjueqtx.html
网友评论