Consider following snippet:
 var a = new Array(); a['key'] = 'value'; alert(a.length);
What value will be displayed in alert box?
Explanation
Expression a['key'] will add a property key to the array object. To add an element to array: a[0] = 'value'; console.log(a) // ['value']

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback