About 87,800 results
Open links in new tab
  1. How do I check for an empty/undefined/null string in JavaScript?

    It works on a null string, and on an empty string and it is accessible for all strings. In addition, it could be expanded to contain other JavaScript empty or whitespace characters (i.e. …

  2. javascript - What is the difference between String.slice and String ...

    Feb 11, 2010 · It's an example of the poor design of JavaScript that we ended up with three methods that all do the same thing, but with different quirks. IMO slice is the one with the least …

  3. How do I write an extension method in JavaScript?

    214 JavaScript doesn't have an exact analogue for C#'s extension methods. JavaScript and C# are quite different languages. The nearest similar thing is to modify the prototype object of all …

  4. javascript - Add method to string class - Stack Overflow

    Jun 7, 2019 · I'd like to be able to say something like this in javascript : "a".distance("b") How can I add my own distance function to the string class?

  5. What is the correct way to check for string equality in JavaScript ...

    In all other cases, you're safe to use ==. Not only is it safe, but in many cases it simplifies your code in a way that improves readability. I still recommend Crockford's talk for developers who …

  6. How to do case insensitive string comparison? - Stack Overflow

    How do I perform case insensitive string comparison in JavaScript?

  7. Reversing a string in JavaScript - Stack Overflow

    May 27, 2017 · To answer your initial question — how to [properly] reverse a string in JavaScript —, I’ve written a small JavaScript library that is capable of Unicode-aware string reversal. It …

  8. Are JavaScript strings immutable? Do I need a "string builder" in ...

    Sep 9, 2008 · They are immutable. You cannot change a character within a string with something like var myString = "abbdef"; myString[2] = 'c'. The string manipulation methods such as trim, …

  9. How can I convert a string to an integer in JavaScript?

    173 There are two main ways to convert a string to a number in JavaScript. One way is to parse it and the other way is to change its type to a Number. All of the tricks in the other answers (e.g., …

  10. What is the difference between string primitives and String objects …

    JavaScript automatically converts primitives to String objects, so that it's possible to use String object methods for primitive strings. In contexts where a method is to be invoked on a primitive …