Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Slice Strings Using Negative Indexes</title> </head> <body> <script> var str = "The quick brown fox jumps over the lazy dog."; document.write(str.slice(-28, -19) + "<br>"); // Prints: fox jumps document.write(str.slice(31)); // Prints: the lazy dog. </script> </body> </html>