1.得到访问的文件地址
<script type="text/javascript">
with(location){
var qs = search.substring(1);
var hostName = hostname; //unavailable when viewing from a local file
var url = href;
}
alert(qs);
alert(hostName);
alert(url);
</script>
<script type="text/javascript">
// == 表示两个对象的toString相等
//===表示两个对象的类型相等且值相等。
alert(null == undefined); //true
alert(null === undefined); //false
alert("NaN" == NaN); //false
alert("NaN" === NaN); //false
alert(NaN == NaN); //false
alert(NaN === NaN); //false
alert(NaN != NaN); //true
alert(NaN !== NaN); //true
alert(false == 0); //true
alert(false === 0); //false
alert(true == 1); //true
alert(true === 1); //false
alert(null == 0); //false
alert(undefined == 0); //false
alert(5 == "5"); //true
alert(5 === "5"); //false
</script>
<script type="text/javascript">
alert(null == undefined); //true
alert(null === undefined); //false
alert("NaN" == NaN); //false
alert("NaN" === NaN); //false
alert(NaN == NaN); //false
alert(NaN === NaN); //false
alert(NaN != NaN); //true
alert(NaN !== NaN); //true
alert(false == 0); //true
alert(false === 0); //false
alert(true == 1); //true
alert(true === 1); //false
alert(null == 0); //false
alert(undefined == 0); //false
alert(5 == "5"); //true
alert(5 === "5"); //false
</script>
<script type="text/javascript">
var result1 = ("55" != 55); //false ?equal because of conversion
var result2 = ("55" !== 55); //true ?not equal because different data types
alert(result1);
alert(result2);
var result1 = ("55" == 55); //true ?equal because of conversion
var result2 = ("55" === 55); //false ?not equal because different data types
</script>
得到window中所有的事件
<script type="text/javascript">
for (var propName in window) {
document.write(propName);
document.write("<br />");
}
</script>
<script type="text/javascript">
for (var propName in window) {
document.write(propName);
document.write("<br />");
}
</script>
方法参数数组
<script type="text/javascript">
function sayHi() {
alert("Hello " + arguments[0] + ", " + arguments[1]);
}
sayHi("Nicholas", "how are you today?");
function howManyArgs() {
alert(arguments.length);
}
howManyArgs("string", 45); //2
howManyArgs(); //0
howManyArgs(12); //1 </script>
<script type="text/javascript">
function sayHi() {
alert("Hello " + arguments[0] + ", " + arguments[1]);
}
sayHi("Nicholas", "how are you today?");
</script>
null的类型
<script type="text/javascript">
var car = null;
alert(typeof car); //"object"
alert(null == undefined); //true </script>
<script type="text/javascript">
var car = null;
alert(typeof car); //"object"
</script>