Javascript slice function will extract data from string or an array. It require two parameters one is start point and second parameter is optional. if negative values are assigned then it will start from the end.
Javascript slice function Example - 2
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<script>
var str = "i love learnkode, the code learning platform.";
var sliced = str.slice(3, -2);
document.write( sliced );
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<script>
var str = "Apples are round, and apples are juicy.";
var sliced = str.slice(-3, -2);
document.write( sliced );
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<script>
var str = "Apples are round, and apples are juicy.";
var sliced = str.slice(4);
document.write( sliced );
</script>
</body>
</html>