I am quite a novice at javascript, but I do have gained an understanding of OOP from PHP.

I have seen RegExp() object being used in some script... BUT I also have seen this being used instead: cls=/ain/gi;

What is the advantage of using an object instead of a simple variable as above?

and at the risk of answering my own question, is there a way to use a variable INSIDE a regex expression when NOT using the RegExp() object?
something like this...


As always .. advice is appreciated and thanks in advance