daytonn
9/13/2011 - 2:46 AM

Strict type checking in javascript

Strict type checking in javascript

var test_string = 'Hello',
      test_array = ['one', 'two', 'three'],
      test_number = 42;
      test_object = { key: 'value' };
      test_function = function() {};

  test_string.constructor == String;// true
  test_array.constructor == Array;// true
  test_number.constructor == Number;// true
  test_object.constructor == Object;// true
  test_function.constructor == Function;// true

  test_string.constructor == Object;// false
  test_array.constructor == Object;// false
  test_number.constructor == Object;// false
  test_object.constructor == Function;// false
  test_function.constructor == Object;// false