Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,851 questions

51,772 answers

573 users

What is the difference between var variable_name = {} and var variable_name = [] in javascript

1 Answer

0 votes
// [] is an array, {} is an object


var arr = []; 

arr[0] = 111;
arr[1] = 222;
arr[5] = 333;

document.write(arr.length + "<br />");
document.write(arr.toString() + "<br />");


var car = {manufacturer:"VOLVO", model:"S90", color:"BLACK", price:47350};
document.write(car.manufacturer + "<br />");
document.write(car.model + "<br />");
document.write(car.color + "<br />");
document.write("$"+car.price + "<br />");;



/*
run:
    
6
111,222,,,,333
VOLVO
S90
BLACK
$47350
 
*/

 



answered Nov 1, 2019 by avibootz

Related questions

...