About 50 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 write an extension method in JavaScript?

    215 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 string objects: …

  3. javascript - How do you reverse a string in-place? - Stack Overflow

    How do you reverse a string in-place in JavaScript when it is passed to a function with a return statement, without using built-in functions (.reverse(), .charAt() etc.)?

  4. What is the difference between string primitives and String objects in ...

    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 string or a …

  5. javascript - Sort string without any builtin methods - Stack Overflow

    I want to sort a string in javascript without using a built in method, just by using for's and comparisons like 'a' > 'b'; Something that doesn't work: function replaceAt(str, i, char) {

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

    174 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., unary …

  7. 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. nonbreaking space, byte …

  8. How do I make the first letter of a string uppercase in JavaScript?

    Jun 22, 2009 · 5409 How do I make the first character of a string uppercase if it's a letter, but not change the case of any of the other letters? For example: "this is a test" → "This is a test" "the Eiffel Tower" …

  9. How do I replace all occurrences of a string? - Stack Overflow

    Note: In general, extending the built-in prototypes in JavaScript is generally not recommended. I am providing as extensions on the String prototype simply for purposes of illustration, showing different …

  10. 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 don't want to …