cross browser - javascript dynamic array declare and initialize with IE -


i have example work fine chrome , firefox

var array = [];

array.a = 1;

array.b = 2;

console.log(array)

in chrome , firefox return a

objectarray [ a:1 b:2 ]

but ie return objectarray[] lenght 0 idea?

{} creates empty literal object (= key-value object). equal new object()

[] creates empty array. equal new array()

example:

var obj = {}; obj.a = 1;     //add key-value console.log(obj);  var array = []; array.push(2);  // add value console.log(array); 

in javascript arrays objects , following statements not cause error , still valid:

var array = []; array.a = 1; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -