2025年02月28日 建站教程
javascript如何利用方法获取当前对象是number
、string
、boolean
等。下面web建站小编给大家详细介绍一下代码!
实例代码如下:
console.log( typeof '1234' ); //检测数字1234,结果为:string console.log( typeof 1 ); //检测数字1,结果为:number console.log( typeof true ); //检测true,结果为:boolean console.log( typeof false ); //检测false,结果为:boolean console.log( typeof undefined ); //检测undefined,结果为:undefined console.log( typeof null ); //检测null,结果为:object console.log( typeof {} ); // 检测对象,结果为:object console.log( typeof [] ); //检测数组,结果为:objec
本文链接:http://so.lmcjl.com/news/24016/