var a = 1; var a = 'x'; console.log(a); //输出'x'
function test() {
console.log("test");
}
test(); //输出 "test arg0 + undefined"
function test(arg1) {
console.log("test arg" + arguments.length + " + " + arg1);
}
test(1,2); //输出 "test arg2 + 1"
function test(arg1) {
for(var i=0; i<arguments.length; i++) {
console.log(arguments[i]);
}
}
test(1,2); //输出 1 2
var a = 100;
function a() {
return "function";
}
console.log(a); //输出 100
console.log(a());
/*
报错
Uncaught TypeError: a is not a function
(anonymous function) @test.html:9
*/
var a = 100;
var a = function() {
return "function";
}
console.log(a);
/*
输出
function() {
return "function";
}
*/
console.log(a()); //输出 "function"
function a() {
console.log(this); //输出 window{...}
this.a = 1; //即 window.a = 1,此时window下的function a已经被该变量覆盖了。
var a = 5; //下面的这几个变量都是局部变量,仅在花括号范围内有效。
a = 10;
var v = "value"
return "function";
}
console.log(a); //输出 function a {...}
console.log(a()); //输出 "function"
console.log(a); //输出 1
console.log(v);
/*
输出
Uncaught ReferenceError: v is not defined
(anonymous function) @ mycolor.html:15
*/
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有