日期:2014-05-16 浏览次数:20424 次
<script type="text/javascript" defer="defer" src="xx.js"></script>
function test() { message = "message" } test(); alert(message) //"message"
alert(typeof "message");//返回string
var message; alert(message == undefined);//返回true
alert(message == undefined);//报错
var message; alert(typeof message);//返回undefined alert(typeof age);//返回undefined
if(true){ var c = "blue"; } alert(c);//返回blue
var str = "hello world"; alert(str.slice(3));//"lo world" alert(str.slice(3,7));//"lo w" alert(str.slice(-3));//"rld" (11+(-3)=8) alert(str.slice(-3,7));//"" str.slice(8,7);不执行,如果str.slice(-9,7)-->"llo w" alert(str.substr(3));//"lo world" alert(str.substr(3,7));//"lo worl" alert(str.substr(-3));//"rld" alert(str.substr(-3,7));//"rld" str.substr(8,7)-->str.substr(8,11). alert(str.substring(3));//"lo world" alert(str.substring(3,7));//"lo w" alert(str.substring(-3));//"hello world" alert(str.substring(-3,7));//"hello w"