Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

add char in specific index stirng javascript

int j = 123456;
String x = Integer.toString(j);
x = x.substring(0, 4) + "." + x.substring(4, x.length);

//output : 1234.56
Comment

add char in specific index stirng javascript


if (!String.prototype.splice) {
    /**
     * {JSDoc}
     *
     * The splice() method changes the content of a string by removing a range of
     * characters and/or adding new characters.
     *
     * @this {String}
     * @param {number} start Index at which to start changing the string.
     * @param {number} delCount An integer indicating the number of old chars to remove.
     * @param {string} newSubStr The String that is spliced in.
     * @return {string} A new string with the spliced substring.
     */
    String.prototype.splice = function(start, delCount, newSubStr) {
        return this.slice(0, start) + newSubStr + this.slice(start + Math.abs(delCount));
    };
}

Comment

PREVIOUS NEXT
Code Example
Javascript :: svelte ondestroy 
Javascript :: window.scroll 
Javascript :: javascript append element to array 
Javascript :: on click jqueyr 
Javascript :: how to test on user reaction discord.js 
Javascript :: npm ERR! missing script: start 
Javascript :: javascript find and replace text in html 
Javascript :: last element of array js 
Javascript :: javascript extract hour from string 
Javascript :: hide component on click vue 
Javascript :: month list javascript 
Javascript :: cypress click 
Javascript :: internal/modules/cjs/loader.js:1122 
Javascript :: scroll event js 
Javascript :: swap key value object javascript 
Javascript :: find duplicate values in array object javascript 
Javascript :: Nuxt: Nuxt auth not redirecting after logout 
Javascript :: Scrollbar inside Dropdown of antD component React 
Javascript :: error: expected undefined to be a graphql schema. 
Javascript :: how to use br tag in javascript string 
Javascript :: on click button change route next js 
Javascript :: es6 remove empty property from object 
Javascript :: javascript quicksort 
Javascript :: javascript style multiple properties 
Javascript :: load base64 image in tab javascript 
Javascript :: Checking Empty JS Object 
Javascript :: get keys of object in an array 
Javascript :: angular get file from assets 
Javascript :: split date 
Javascript :: npm run shell script 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =