一些javascript 变量声明的 疑惑

关于以下这些变量定义的一些疑惑 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
***/
原文地址:https://www.cnblogs.com/senion/p/2169315.html