如题所述
typeof æä½ç¬¦
对äºFunctionï¼ Stringï¼ Number ï¼Undefined çå ç§ç±»åç对象æ¥è¯´ï¼ä»å®å ¨å¯ä»¥èä»»ï¼ä½æ¯ä¸ºArrayæ¶
1
vararr=newArray("1","2","3","4","5");
2
alert(typeof(arr));
ä½ ä¼æ¶å°ä¸ä¸ªobject ççæ¡ï¼æç¹è®©äººå¤±æã
instanceof æä½ç¬¦
JavaScriptä¸instanceofè¿ç®ç¬¦ä¼è¿åä¸ä¸ª Boolean å¼ï¼æåºå¯¹è±¡æ¯å¦æ¯ç¹å®ç±»çä¸ä¸ªå®ä¾ã 使ç¨æ¹æ³ï¼result = object instanceof class,è¿æ¯ååçæ°ç»ï¼åæ¥ä¸æ¬¡ï¼å¯ï¼æåçè¿å trueã
对äºFunctionï¼ Stringï¼ Number ï¼Undefined çå ç§ç±»åç对象æ¥è¯´ï¼ä»å®å ¨å¯ä»¥èä»»ï¼ä½æ¯ä¸ºArrayæ¶
1
vararr=newArray("1","2","3","4","5");
2
alert(typeof(arr));
ä½ ä¼æ¶å°ä¸ä¸ªobject ççæ¡ï¼æç¹è®©äººå¤±æã
instanceof æä½ç¬¦
JavaScriptä¸instanceofè¿ç®ç¬¦ä¼è¿åä¸ä¸ª Boolean å¼ï¼æåºå¯¹è±¡æ¯å¦æ¯ç¹å®ç±»çä¸ä¸ªå®ä¾ã 使ç¨æ¹æ³ï¼result = object instanceof class,è¿æ¯ååçæ°ç»ï¼åæ¥ä¸æ¬¡ï¼å¯ï¼æåçè¿å trueã
温馨提示:答案为网友推荐,仅供参考