Skip to Main Content
Head Rush Ajax
book

Head Rush Ajax

by Brett McLaughlin
March 2006
Beginner to intermediate content levelBeginner to intermediate
448 pages
13h 33m
English
O'Reilly Media, Inc.
Content preview from Head Rush Ajax
you’re on your way 4
179
asynchronous applications
Introducing the JavaScript substring() function
JavaScript has a function that’s just perfect for taking a string like the coffee
maker is returning, and breaking it up into a few parts. Here’s how you use
the substring() function:
var newString = myString.substring(startIndex, endIndex);
myString is the variable that
holds the string you want to
break up into several smaller parts.
newString is the smaller
substring returned by JavaScript.
substring() is the JavaScript
function you can use to break
down strings into smaller parts.
startIndex is the position in
myString you want your substring
to begin at. Remember, “0”
is the position of the rst
character, not “1”.
1Jim
0
1
2
3
Position:
myString
You can use myString.length to get
the length of a string, which will
always be one greater than the
last position in the string.
endIndex is the position in myString
that you want your substring to end
at. The character at this poisition is
not included in the substring.
4
myString.length
It may help you to think of
substring() as creating a string
from position startIndex to
position (endIndex - 1).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
Head First Ajax

Head First Ajax

Rebecca M. Riordan

Publisher Resources

ISBN: 0596102259Errata PageSupplemental Content