H I O X INDIA
Javascript Tutorial
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





Javascript Variable String


Topic

How can we use a string in javascript?
How to use the special characters '(quote), "(double quote), \(backslash), newline, tab in javascript string variable?



Explanation

String- E.g: "sdfesdfe"
For a variable to be a string type, the value assigned should be given in quotes.
A number given within quotes will be considered only as a string and not as an integer.
i.e if
var a = "2";
var b = "2";
then a+b will give "22" and not 4.


Special Character's: To use the special characters like tab, newline, back space, double quotes, etc.. in string variable the following format should be used

CharacterCode to be used
Single Quote\'
Double Quote\"
Backslash\\
Horizontal Tab\t
New Line\n
Back Space\b
Carriage Return\r

Example Code:
<script language="javascript">
var as = "this is \"a\" \'test\'";
document.write(as);
</script>


Result:
this is "a" 'test'


        Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

others

privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links