What will be the output of the following code snippet..?

What will be the output of the following code snippet?

< script type=“text/javascript” language=“javascript”>

var a = “Scaler”;
var result = a.substring(2, 4);
document.write(result);

< /script>
1)al

2)ale

3)cal

4)caler

1 Like

the correct ans is 1)al

2 Likes

the correct ans is : al

1 Like

the correct answer al

The substring function in javascript slices a substring out of a given string from the start to end indexes(excluding the end index). So the 2nd and 3rd characters are taken here(0-based indexing) and the answer is al.