javascript判断对象

 1 var assert = require('chai').assert;
 2 
 3 describe('Array', function() {
 4   describe('#indexOf()', function() {
 5     it('should return -1 when the value is not present', function() {
 6         
 7         var obj = {};
 8         var array  = []; 
 9         var date = new Date();
10 
11         var fn = function() {
12         }
13         
14         var _null = null;
15         
16         assert.equal('[object Object]', Object.prototype.toString.call(obj));
17         assert.equal('[object Array]', Object.prototype.toString.call(array));
18         assert.equal('[object Date]', Object.prototype.toString.call(date));
19         assert.equal('[object Function]', Object.prototype.toString.call(fn));
20         
21         assert.equal('[object Null]', Object.prototype.toString.call(_null));
22     });
23   });
24 });

原文地址:https://www.cnblogs.com/maduar/p/5738939.html