Αποτελέσματα Αναζήτησης
5 Ιουν 2016 · you can write your own format extension like this: String.prototype.myFormatString = function(_array){ var s = _array[0]; for (var i = 0; i < _array.length - 1; i++) { var reg = new RegExp("\\{" + i + "\\}", "gm"); s = s.replace(reg, _array[i + 1]); } return s; } and call it in your code:
4 Μαρ 2009 · I'm looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() (IFormatProvider for .NET). My basic requirement is a thousand separator format for numbers for now, but something that handles lots of combinations (including dates) would be good.
4 Οκτ 2023 · Splits a String object into an array of strings by separating the string into substrings. slice() Extracts a section of a string and returns a new string. substring(), substr() Return the specified subset of the string, either by specifying the start and end indexes or the start index and a length.
JavaScript String Format - in 3 Ways. In this article, you are going to learn what is string formatting or string interpolation in JavaScript, different JavaScript string format methods, creating a function to format a string, and how to use string formatting in JavaScript.
25 Ιουλ 2024 · The String object is used to represent and manipulate a sequence of characters. Description. Strings are useful for holding data that can be represented in text form.
2 Σεπ 2024 · JavaScript Strings are used to print an array of characters and are a primitive data type. While creating and printing strings we sometimes want to add values from other variables or concatenate multiple strings to create a single string. To solve this issue we use formatting.
19 Αυγ 2024 · Define a function that takes a format string and arguments. function formatString ( str, ...args ) { // Implement custom formatting logic here return str.replace( /%s/g , args.shift()); // Example for simple placeholder replacement }