标签:
一、严格模式
use strict
IE10+Firefox 4+Safari 5.1+Opera 12+Chrome
function test(){var message="h1";//局部变量}test();console.log(message);//报错
function test(){message="h1";}test();console.log(message);//输出“hi”
UndefinedNullBooleanNumberString
Object//本质上是由一组无序名值对组成的
//对一个值使用typeof操作符可能返回以下某个字符串"undefined"//如果这个值未定义"boolean"//如果这个值是布尔值"string"//如果这个值是字符串"number"//如果这个值是数值"object"//如果这个值是对象或者null"function"//如果这个值是函数
var int1;var int2=true;var int3="sun";var int4=1;var int5=new Object();int5.name="zhou";int5.age=5;var int6=function(){document.write(你好);};console.log(typeof(int1));console.log(typeof(int2));console.log(typeof(int3));console.log(typeof(int4));console.log(typeof(int5));console.log(typeof(int6));- /*输出为:
- "undefined" js19.html:17 "boolean" "string" "number" "object" "function"
- */
var message="some string"alert(typeof message);alert(typeof (message));alert(typeof 95);
标签:
原文地址:http://www.cnblogs.com/Zjingwen/p/4455665.html