
November 26th, 2012, 06:54 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Hi,
use slice() with a negative end index:
Code:
var extr = str.slice(0, -16);
A negative index will count from the end of the string, beginning with -1. Be careful with the start index: It begins with 0, so when you use 1, you'll lose the first character.
Another possibility would be to simply take the string length and substract 16:
Code:
var extr = str.substr(0, str.length - 16);
|