//公共js
function log(){
console.log(...arguments);
}
//1
log([]+[]+'f00'.split(''));//f,0,0
//2
log(new Array(5).toString());//,,,,
//3
log((true+false)>2+true);//false
//true+false=1
//2+true=3
//4
var num4=function Fn4(){
log(typeof Fn4)
}
num4();//function
log(typeof Fn4);//undefined
//5
var num5=1;
if (function Fn5(){}) {
num5+=typeof Fn5;
}
log(num5);//1undefined
//6
function fun(n,o){
log(o);
return {
fun:function(m){
return fun(m,n);
}
}
}
var fn1=fun(0);
fn1.fun(1);
fn1.fun(2);//undefined,0,0
var fn2=fun(0).fun(1).fun(2);//undefined,0,1
var fn3=fun(0).fun(1);
fn3.fun(2);
fn3.fun(3);//undefined,0,0,0
//7
var fn7;
log(typeof fn7); //function
function fn7(x){
return x*2
}
var fn7;
log(typeof fn7); //function
var fn7=1;
log(typeof fn7); //number
//函数优先级大于变量优先级
//8
var x=2,y=1;
function fn8(){
var x=3;
return {
x:x,
fn:function(a,b){
x=a+b;
}
}
}
var num8=fn8();
num8.fn(4,4);
log(num8.x,x)
//答案:3,2
//9
var a=0,b=0;
function A(a){
A=function(b){
log(a+b++)
}
log(a++)
}
A(1);//1,将A赋值新的函数,a++:先输出a,再对a+1
A(2);//4,
//10
https://www.adtk.cn
网友评论