JavaScript recognizes the following types of values:
var answer = 42
And later, you could assign the same variable a string value, for example,
answer = "Thanks for all the fish..."
Because JavaScript is loosely typed, this assignment does not cause an error message.
In expressions involving numeric and string values, JavaScript converts the numeric values to strings. For example, consider the following statements:
x = "The answer is " + 42
y = 42 + " is the answer."
For more information on these functions, see Chapter 9, "Built-in objects and functions."
JavaScript provides several special functions for manipulating string and numeric values:
A JavaScript identifier, or name, must start with a letter or underscore ("_"); subsequent characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).
Some examples of legal names are Number_hits, temp99, and _name.
You can declare a variable in two ways:
For information on using variables across frames and windows, see Chapter 3, "Using windows and frames."
Some examples of integer literals are: 42 0xFFF, and -345.
Some examples of floating-point literals are 3.1415, -3.1E12, .1e12, and 2E-12
The Boolean type has two literal values: true and false.
Character | Meaning |
---|---|
\b |
backspace |
\f |
form feed |
\n |
new line |
\r |
carriage return |
\t |
tab |
\\ |
backslash character |
You can insert quotation marks inside strings by preceding them with a backslash. This is known as escaping the quotation marks. For example,
var quote = "He read \"The Cremation of Sam McGee\" by R.W. Service."
document.write(quote)
He read "The Cremation of Sam McGee" by R.W. Service.
To include a literal backslash
inside a string, you must escape the backslash character. For example, to
assign the file path c:\temp
to a string, use the following:
var home ="
c:\\temp"
file: /Techref/language/java/SCRIPT/ident.htm, 11KB, , updated: 2009/2/2 14:27, local time: 2024/9/30 15:11,
3.147.75.60:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://piclist.com/tecHREF/language/java/SCRIPT/ident.htm"> Values, variables, and literals </A> |
Did you find what you needed? |
PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.