JavaScript基础(14)—typeof运算符

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>javascript025.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

  </head>
  
  <body>
	<!--
    	typeof运算符:
        	js是一门弱类型语言,不代表js是没有类型的。
            那么,我们怎么能够知道js的类型呢?
            这个时候js就提供了typeof运算符供我们使用。
            
            格式:
            	typeof 表达式
    -->
    <script type="text/javascript">
		//定义数据
		/*
		var x = 10;
		var y = "hello";
		var z = true;
		alert(typeof x); //number
		alert(typeof y); //string
		alert(typeof z); //boolean
		*/
		
		//那么,js中哪些内容可以被看做是引用类型的呢
		//内置对象:Array,Date,Math,String...
		var arr = new Array();
		//alert(typeof arr); //object 这是一个对象
		alert(typeof Array); //function
		
		var date = new Date();
		//alert(typeof date); //object
		alert(typeof Date); //function
		
		var str = new String("hello");
		//alert(typeof str); //object
		alert(typeof String); //function
		
		//三次结果都是function。
		//说明了我们其实是可以通过function模拟类的定义。
	</script>
  </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值