ECMAScript中typeof的用法實(shí)例
來(lái)源:懂視網(wǎng)
責(zé)編:小采
時(shí)間:2020-11-27 19:33:10
ECMAScript中typeof的用法實(shí)例
ECMAScript中typeof的用法實(shí)例:本篇文章分享給大家的內(nèi)容是關(guān)于ECMAScript 中typeof的用法實(shí)例,內(nèi)容很詳細(xì),接下來(lái)我們就來(lái)看看具體的內(nèi)容,希望可以幫助到有需要的朋友。typeof 返回變量的類(lèi)型字符串值 、其中包括 object、number、string、undefined、b
導(dǎo)讀ECMAScript中typeof的用法實(shí)例:本篇文章分享給大家的內(nèi)容是關(guān)于ECMAScript 中typeof的用法實(shí)例,內(nèi)容很詳細(xì),接下來(lái)我們就來(lái)看看具體的內(nèi)容,希望可以幫助到有需要的朋友。typeof 返回變量的類(lèi)型字符串值 、其中包括 object、number、string、undefined、b

本篇文章分享給大家的內(nèi)容是關(guān)于ECMAScript 中typeof的用法實(shí)例,內(nèi)容很詳細(xì),接下來(lái)我們就來(lái)看看具體的內(nèi)容,希望可以幫助到有需要的朋友。
typeof 返回變量的類(lèi)型字符串值 、其中包括 “object”、“number”、“string”、“undefined”、“boolean”、
1、在變量只聲明、卻不初始化值 Or 在變量沒(méi)有聲明時(shí) 返回 “undefined”
> > 'undefined'
> typeof e
'undefined'
>
2、所有引用對(duì)象,返回”object“
> a = > 'object'
> b = String("str"> 'object'
> c = Boolean(> 'object'
>
> var d = []
undefined
> typeof d
'object'
>
> var e = {}
undefined
> typeof e
'object'
>
3、根據(jù)變量值返回對(duì)應(yīng)類(lèi)型 “string”、“number”、“boolean”
> var a = 98undefined> typeof a'number'
> var b = 'aaa'undefined> typeof b'string'
> var c = trueundefined> typeof c'boolean'
>
相關(guān)推薦:
JavaScript學(xué)習(xí)中常會(huì)遇到的js事件處理程序
對(duì)Element UI table組件的源碼的詳細(xì)分析
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
ECMAScript中typeof的用法實(shí)例
ECMAScript中typeof的用法實(shí)例:本篇文章分享給大家的內(nèi)容是關(guān)于ECMAScript 中typeof的用法實(shí)例,內(nèi)容很詳細(xì),接下來(lái)我們就來(lái)看看具體的內(nèi)容,希望可以幫助到有需要的朋友。typeof 返回變量的類(lèi)型字符串值 、其中包括 object、number、string、undefined、b