About 84,100 results
Open links in new tab
  1. javascript - What is the difference between String.slice and String ...

    Feb 11, 2010 · Syntax: string.slice(start, stop); Syntax: string.substring(start, stop); What they have in common: If start equals stop: returns an empty string If stop is omitted: extracts characters to the end …

  2. How do I chop/slice/trim off last character in string using Javascript ...

    This works for removing the last character, but beware if you want to remove a variable number of characters; .slice(0, -0) will return an empty string!

  3. How to slice string from the end in JavaScript? - Stack Overflow

    Feb 18, 2017 · 74 You have to use negative index in String.prototype.slice() function. using negative index as first argument returns the sliced string to the 6 elements counting from the end of the string.

  4. javascript - Is there a splice method for strings? - Stack Overflow

    The Javascript splice only works with arrays. Is there similar method for strings? Or should I create my own custom function? The substr(), and substring() methods will only return the extracted s...

  5. JavaScript equivalent of python string slicing - Stack Overflow

    4 SLICE Slice is a JavaScript implementation of Python's awesome negative indexing and extended slice syntax for arrays and strings. It uses ES6 proxies to allow for an intuitive double-bracket …

  6. javascript - How do I split a string, breaking at a particular ...

    8 split() method in JavaScript is used to convert a string to an array. It takes one optional argument, as a character, on which to split. In your case (~). If splitOn is skipped, it will simply put string as it is on …

  7. How to trim a string to N chars in Javascript? - Stack Overflow

    15 Prefer String.prototype.slice over the String.prototype.substring method (in substring, for some cases it gives a different result than what you expect). Trim the string from LEFT to RIGHT:

  8. Split large string in n-size chunks in JavaScript - Stack Overflow

    I would like to split a very large string (let's say, 10,000 characters) into N-size chunks. What would be the best way in terms of performance to do this? For instance: "1234567890" split by 2 w...

  9. javascript - Replace a string slice - Stack Overflow

    Nov 22, 2012 · This seems absurdly simple, but I'm having trouble thinking of a clean way to do this. Consider: var str = "foo bar foo bar foo bar"; I want to replace the second "foo bar" instance (i.e., str.

  10. javascript - Slice a string at character - Stack Overflow

    Jun 20, 2022 · Im pretty new to js so I hope this isnt a dumb question. Im trying to slice the username string after a certain character ("."). This is what Ive tried so far. Original Username: …