|
One of the basic tenets of programs is that
they have to work on data. Data is any type of information
with which you are working. Data can be words, such as "Hello
There", or numbers, such as 42 or 381.33. In any case,
different programming languages enable you to work on different
kinds of data. JavaScript has five fundamental data types:
String, Number, Boolean, Object and Null.
|
|
Strings |
|
|
Numbers |
|
|
Boolean |
|
|
Null |
A string is any grouping of characters that
is surrounded by either double quotation marks (") or
single quotation marks ('). Strings are used anytime you want
to use text in a program. Single quotes are used when you
want to use double quotes in the string.
Example :
"Welcome"
'Good Morning'
'A string that contains "double quotes"'
JavaScript is quite flexible in the ways
it enables you to represent numbers. Many programming languages
make you divide ahead of time what type of number you will
be using.
Example :
18
104.2
0.058
A Boolean is the simplest data type available.
A Boolean value has only two possible values-true and false.
They are often used to represent whether something has been
done or not.
Example :
static boolean ans;
static String first="were";
static String second="where";
if (first= =second)
{
ans=true;
}
else
{
ans=false;
}
class first
{
String s;
public static void main(String
args[ ])
{
first
my = new first();
System.out.println(my.s);
}
}
Copyrights : Layout Galaxy All Rights Reserved
No part of this tutorial may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, electrostatic, magnetic tape, mechanical or otherwise, without prior permission in writing from Layout Galaxy.
|
|