Monday, June 29, 2015

Number Systems

*** VAR is being phased out use LET instead ***

The VAR is the most important building block in javascripts arsenal. Unlike C, C++, C#, all data types are declared with VAR. Javascript figures out how you want to use it.

var str = "hello there";

Will create a string.

var num = 128;

Will create a number equal to 128 in decimal.

var snum = str + num;

Will create the string "hello there128"

Take the basic HTML5 template and add the extra following code.

You can format numbers into different number systems and display them as strings.
The output of this HTML5 file is:
The first is 128 in binary, Second is 128 in octal, finally 128 in hexadecimal. This comes in very handy as you will soon see.

No comments:

Post a Comment