Suppose that I am storing a value, abcdef in a variable say x in JavaScript and I have to remove abc. The output should hence be def. How to go about this? Please don’t go about delete via number of characters to be deleted as what I am interested is deleting a specific string, it can be or 3 or 4 characters. So, I need a more generalized approach to this.
Share
replace()can be used for replacing (or removing) a static substring (or pattern) from a string.By your example: