O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Splicing Strings

var s1 = "The play's the thing"; var s2 = s1.splice(4,8); // s2 = "play"

You can carve a string into substrings using .splice(start, end) by specifying the starting index and the ending index. The section of the string starting with the character at the index specified by start and ending with the character just before end index is returned. All indexes are zero based.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required