关于以下这些变量定义的一些疑惑 var a={},b=[],c=function(){},d=(function(){}){};

  1. 1 var obj1={

  pro1:2,

  pro2:"ss",

  pro3:function(){}

};

typeof obj1

for(var pp in obj1){

  console.log("typeof "+pp+ " is "+(typeof pp)+" value "+ obj1[pp]);

}

/******

object

typeof pro1 is string value 2
typeof pro2 is string value ss
typeof pro3 is string value function () { return 1; }

***/ 

  1. 2 var obj2=["a","数组?",1,function(){}];

typeof obj2

for(var pp in obj2){

  console.log("typeof "+pp+ " is "+(typeof pp)+" value "+ obj2[pp]);

}

/××××××××

object

typeof 0 is string value a
typeof 1 is string value 数组?
typeof 2 is string value 1
typeof 3 is string value function () { return "sping"; }

××××/ 

  1. 3 var obj3=function(){return 4;};

  typeof obj3

obj3()

/**
function
4
**/
  1. 4 var obj4=(function(im)

{

var im=im||"ss";

return im;

})();

typeof obj4 
obj4
obj4()
/***
string 
ss
error
***/

相关文章:

  • 2021-07-31
  • 2021-08-12
  • 2022-02-16
  • 2022-12-23
  • 2021-12-16
  • 2021-08-16
  • 2021-08-10
猜你喜欢
  • 2022-02-05
  • 2021-11-29
  • 2021-11-08
  • 2021-06-07
  • 2021-11-13
相关资源
相似解决方案