You are viewing a single comment's thread from:

RE: Arrays in JavaScript

in #javascript5 years ago

What you did was the recommended way to assign values to array items. Now that you know howe to assign values to variables, another way to do the same task would be:

var anString = "Hello, World!";
var aNumber = 42;
var aBoolean = true;
var anArray = new Array();

anArray[0] = aString;
anArray[1] = aNumber;
anArray[2] = aBoolean;

But, as I said, your way is the best one, as JavaScript engine will create the Array object for you and assign the values.

Now you are using console.log to verify your results. Soon you will learn the best way is to use a debugger, as it helps you see what is happening on your code instead of seeing the results of it.

Sort:  

Thanks a lot! I'm a complete newbie at coding so this will take some time to sink in...

Posted using Partiko Android

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 61420.98
ETH 3276.21
USDT 1.00
SBD 2.47