Mastering Variables - Page 2


© Muhammad Ali Shah
Page 2
var name;
name = "Muhammad Ali Shah"; // alphanumeric
var i; i = 5*10; // an integer



Data Types:

JavaScript is a loosely typed language - you don't have to define what type of contents a variable can have and JavaScript automatically handles conversions between different data types. For example suppose you want to write i = 5.0 * 1. In this case, 5.0 is a real (recall your Arithmetic lessons) and 1 is an integer. JavaScript automatically handles the conversion from integer to real for multiplication. You may be surprised to know that certain languages do not allow such operations!

Although you will never define the data type of a variable in JavaScript, knowing various categories of variables is very helpful:



Summary:

JavaScript is a loosely typed and case sensitive scripting language. It also differs in a local and global variables. JavaScript provides automatic conversion between variables and constants of different data types and you don't declare the data type of a variable while defining it. A variable is defined by a var statement.

Go To Page: 1 2 3


The copyright of the article Mastering Variables - Page 2 in JavaScript is owned by . Permission to republish Mastering Variables - Page 2 in print or online must be granted by the author in writing.

Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo