Types of Variables

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email
Variables are used to store values. Variable names can have uppercase letters(A-Z) ' lowercase letters(a-z),digits(0-9), underscore( - ).The first character should be an alphabet or an underscore. Variables cannot have blank spaces or other punctuation marks. Variables are case sensitive Variable names can be of any length. Variables are defined with the optional keyword var. Unlike other programming languages , JavaScript does not require you to specify the type of data contained in a variable. The same variable can hold different values such as string, integer, Boolean etc,.

Variables 1. Number
2. Boolean
3. String
4. Null
5. Undefined

Number - It can be an integer number,floating point number or a special value called NaN(Not a Number).

Boolean - It can have logical values true and false.

String - It can have string values enclosed in single or double quotes.

Null - It consists of a single value null which defines empty or non existent reference.

Undefined : It has a single value undefined, which indicates that a variable has not been assigned a value.

Number types

Number is of two types namely:

1 . Integer

2. Floating Point

Integer literals can be represented in three different bases: 1 . A decimal integer which consists of digits from 0 through 9
2. A hexadecimal integer begins with Ox or OX
3. An octal number begins with 0.

Floating Point literals

Floating point literals are used to represent numbers with decimal point or numbers. String values can be given within single or double quotes. To include quotes or double quotes within strings special formatting characters have to be used. The following are some of the formatting characters:

\' - single quote
\" - double quote
\\ - backslash
\t - horizontal tab
\n - newline
\b - backspace
\r - carriage return
\f - form feed

<html>
<head>
<title>My First JavaScript Program</title>
<pre>
<script language="JavaScript">
<!--
document.write("Welcome to Pentasoft">
document .write("This is \t your first session")
document.write("You would be learning \n about JavaScript")
//-->
</script>
</pre>
</head>
</html>



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.