Skip to content

Tag: reactjs

How to replace string using regex in javascript?

How to check a string and replace the space into “_” ? Please help me out 🙂 Answer Check this out. I think it’s gonna help Hints: /:(w+s*)+/g Separates the :nokibul amin mezba jomadder as a group. Replace the group with index-wise templating {0}, {1} … {n}. Mapping the groups. Ex: :nok…

Typescript: Limit Return Value but not Parameter

I wish to pass in a function as a parameter but limit the passed function’s return type but not its parameters. Ex: function Car(driver: Function), where driver can be ()=>boolean or (first, second) => boolean. The driver must take a function with return type boolean but have any number of paramet…