Javascript数据类型共有六种
Javascript数据类型共有六种
/* var box; alert(typeof box); // box是Undefined类型,值是undefined,类型返回的字符串是undefined var box = true; alert(typeof box); // box是Boolean类型,值是true,类型返回的字符串是boolean var box = 'a'; alert(typeof box); // box是String类型,值是'a',类型返回的字符串是string var box = 123; alert(typeof box); // box是Number类型,值是123,类型返回的字符串是number var box = {}; alert( box); // box是Object类型,值是[object Object],类型返回的字符串是object var box = null; alert( box); // box是Null类型,值是null,类型返回的字符串是object var box = new Object(); alert( box); // box是Object类型,值是[object Object],类型返回的字符串是object 共有以上六种数据类型;function不是数据类型; function box(){ } alert(typeof box);// box是Function函数,值是function box(){},类型返回的字符串是function typeof可以直接写入自变量; alert(typeof nulla); // 这个返回undefined,但是nulla 是 is not defined */ alert(typeof nulla);
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步