Its output is as follows Apples are round substr This method returns the

Its output is as follows apples are round substr this

This preview shows page 110 - 114 out of 189 pages.

Its output is as follows: [ 'Apples', 'are', 'round,' ] substr() This method returns the characters in a string beginning at the specified location through the specified number of characters. Syntax
Image of page 110
TypeScript 102 string.substr(start[, length]); Argument Details start − Location at which to start extracting character s (an integer between 0 and one less than the length of the string). length − The number of characters to extract. Note If start is negative, substr uses it as a character index from the end of the string. Return Value The substr() method returns the new sub-string based on given parameters. Example var str = "Apples are round, and apples are juicy."; console.log("(1,2): " + str.substr(1,2)); console.log("(-2,2): " + str.substr(-2,2)); console.log("(1): " + str.substr(1)); console.log("(-20, 2): " + str.substr(-20,2)); console.log("(20, 2): " + str.substr(20,2)); On compiling, it will generate the same code in JavaScript. Its output is as follows: (1,2): pp (-2,2): y. (1): pples are round, and apples are juicy. (-20, 2): nd (20, 2): d substring() This method returns a subset of a String object. Syntax string.substring(indexA, [indexB])
Image of page 111
TypeScript 103 Argument Details indexA − An integer between 0 and one less than the length of the string. indexB − (optional) An integer between 0 and the length of the string. Return Value The substring method returns the new sub-string based on given parameters. Example var str = "Apples are round, and apples are juicy."; console.log("(1,2): " + str.substring(1,2)); console.log("(0,10): " + str.substring(0, 10)); console.log("(5): " + str.substring(5)); On compiling, it will generate the same code in JavaScript. Its output is as follows: (1,2): p (0,10): Apples are (5): s are round, and apples are juicy. toLocaleLowerCase() This method is used to convert the characters within a string to lowercase while respecting the current locale. For most languages, it returns the same output as toLowerCase. Syntax string.toLocaleLowerCase( ) Return Value Returns a string in lowercase with the current locale. Example var str = "Apples are round, and Apples are Juicy."; console.log(str.toLocaleLowerCase( )); On compiling, it will generate the same code in JavaScript. Its output is as follows:
Image of page 112
TypeScript 104 apples are round, and apples are juicy. toLocaleUpperCase() This method is used to convert the characters within a string to uppercase while respecting the current locale. For most languages, it returns the same output as toUpperCase. Syntax string.toLocaleUpperCase( ) Return Value Returns a string in uppercase with the current locale. Example var str = "Apples are round, and Apples are Juicy."; console.log(str.toLocaleUpperCase( )); On compiling, it will generate the same code in JavaScript. Its output is as follows: APPLES ARE ROUND, AND APPLES ARE JUICY. toLowerCase() This method returns the calling string value converted to lowercase. Syntax string.toLowerCase( ) Return Value Returns the calling string value converted to lowercase.
Image of page 113
Image of page 114

You've reached the end of your free preview.

Want to read all 189 pages?

  • Fall '19
  • Prof. Solomon Derese
  • Type system, Type theory, Typescript

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture