why does .replace method use forward slash characters to enclose the first argument?
- by Phillip Dodd
I am working through a book about Javascript and have encountered the following example of code designed to replace the value of the class attribute of a table header HTML element:
th.className = th.className.replace(/asc/,"dsc");
th.className = th.className.replace(/dsc/,"asc");
Why is the first parameter of .replace, the current value of th.className, enclosed in forward slashes instead of quotation marks?
Why not use quotation marks to enclose both parameters, not just the second one?
Thank you in advance for any help given. First time posting, apologies if I duplicated a question despite searching the site before posting.