What does substitution mean (/ \ n / g, "something")?

I met this code many times and never understood what it means

/\n/g
+4
source share
1 answer

This will replace the entire newline character in your string with something.

i.e 
    var str="ruhul\nruhul"
    console.log(str)
    console.log(str.replace(/\n/g,"hello"));
+6
source

Source: https://habr.com/ru/post/1651737/


All Articles