Multiple choice

Which of the following statements is false regarding the 'substring' function having the above syntax?

string.substring(index1,index2);

  1. If index1 equals index1, substring returns an empty string.

  2. If any of the argument is less than 0 it is considered as 0.

  3. If index2 is not specified, substring extracts characters till the end of the string.

  4. If either argument is greater than the length of the string, it is considered as the same value as stringName.length.

  5. It is compulsory to pass at least one argument while calling the substring() function.

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

It is not compulsory to pass an argument while calling the substring() function. If no arguments are specified, the actual string will be printed as it is. In the following example, the output will be 'welcome'

var str=welcome;document.write(str.substring());