本篇文章分享给大家的内容是关于ecmascript 中typeof的用法实例,内容很详细,接下来我们就来看看具体的内容,希望可以帮助到有需要的朋友。
typeof 返回变量的类型字符串值 、其中包括 “object”、“number”、“string”、“undefined”、“boolean”、
1、在变量只声明、却不初始化值 Or 在变量没有声明时 返回 “undefined”
> > 'undefined' > typeof e 'undefined' >
2、所有引用对象,返回”object“
> a = > 'object' > b = String("str"> 'object' > c = Boolean(> 'object' > > var d = [] undefined > typeof d 'object' > > var e = {} undefined > typeof e 'object' >
3、根据变量值返回对应类型 “string”、“number”、“boolean”
> var a = 98undefined> typeof a'number' > var b = 'aaa'undefined> typeof b'string' > var c = trueundefined> typeof c'boolean' >
相关推荐:
以上就是ECMAScript 中typeof的用法实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号