Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)
Can anyone help me how I can able to slice the string from the end?

1 Answer

0 votes
by (26.7k points)

You can very well use the negative indexing in String.prototype.slice() function like:

var example = "javascript";

console.log(example.slice(-6));

Or,

var example = "javascript";

console.log(example.slice(0, -6));

I hope this will help.

Want to become a Java Expert? Join Java Certification now!!

Want to know more about Java? Watch this video on Java Tutorial for Beginners | Java Programming:

Related questions

Browse Categories

...