-1

I'm trying to cut off string in PreactJS as follow,

mystring.subString(0, 10)

unfortunately, error found that 'subString' undefined or something else seem it does not work. Please let me know how to do it?

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
PPShein
  • 13,309
  • 42
  • 142
  • 227

2 Answers2

0

This has nothing to do with Preact, it's a syntax error

It should be : 'mystring'.substring(0, 10)

Daniel Andrei
  • 2,654
  • 15
  • 16
0

@daniel is correct. And the following is also possible :-

'mystring'.substr(0, 10)

Srk95
  • 139
  • 1
  • 8
  • 1
    Using substr is _possible_ but **strongly discouraged**. See the [doc of the function on the MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) or [a related question on SO](https://stackoverflow.com/questions/52640271/why-string-prototype-substr-seems-to-be-deprecated). – Lex Lustor Jan 15 '19 at 10:05