typeof is a simple JS operator which returns typeof the element passed.
Try this :
var test_array = Array(); test_array.length; //returns 0 this time test_array = 'I am hundred'; test_array.length; //returns 101 now
var test_array = Array(); test_array.length; //returns 0 this time test_array['key1'] = 'I am key 1'; test_array['key2'] = 'I am key 2'; test_array.length; //again 0
- The fact above also concludes that JS objects dont have any length property, so we cannot determine whether an object is empty or not with the length property.
Really nice article.