Q:

Write a JavaScript program to clone a given regular expression

0

Write a JavaScript program to clone a given regular expression.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
const regExp = /lorem ipsum/gi;
console.log(regExp);
const regExp2 = cloneRegExp(regExp);
console.log(regExp2);

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now