1

Topic: substrAfterLast

? We assume, there is a function substrAfterLast which returns the substring beginning with last met delimiter', transferred in the given function. Implementation on JS: String.prototype.substrAfterLast = function (delim) {return this.substr (this.lastIndexOf (delim) + 1);}; usage Example: var path = ' /path/to/file.txt '; console.log (path.substrAfterLast ('/));//file.txt As you consider, what such function should return in the event that in this has not been found the character specified by the user? var path = ' file.txt '; console.log (path.substrAfterLast ('/));//??? Blank line? All initial line entirely? .

2

Re: substrAfterLast

Hello, b0r3d0m, you wrote:  here . If a separator - the last character in line - that blank line. If the separator is not found - that None (null/undefined).

3

Re: substrAfterLast

Hello, b0r3d0m, you wrote: B> Poflejmim? B> we Assume, there is a function substrAfterLast which returns the substring beginning with last met delimiter', transferred in the given function. B> implementation on JS: B> B> String.prototype.substrAfterLast = function (delim) {B> return this.substr (this.lastIndexOf (delim) + 1); B>}; B> B>... B> As you consider, what such function should return in the event that in this has not been found the character specified by the user? B>... B> blank line? How to distinguish from a situation if a separator in a line end? B> all initial line entirely? The artful idler. Rewrite implementation. Decided to spare on check on-1 and to return substr (-1 + 1)? Whether Not too heavy there will be a check on that that the separator is not found? You will check equality of lines? Or under the scenario such situation very rare and you agree to check equality of lines at an exceptional situation. It is possible to return null, as a sign  a separator.

4

Re: substrAfterLast

5

Re: substrAfterLast