+ 6
Javascript coding question
this may seem very stupit but i have no idea,am just asking what is the difference between switch statements ,an array and and an object in JavaScript ,i knw they all store many values but I have no idea which is used where,,,little help
2 Answers
+ 3
First of all, switch doesnt store a value but rather checks a value against options, which is comparable to if-statements.
Next, think of an array as an container of variables that all have the same data type, so you use it if you need to store some more variables of the same data type.
Last, an object is somewhat similar to an array, but it can have variables of different data types, and those are written in key::value pairs instead of simple index numbers.
You usually use objects to represent things from the real world.
0
no