why does .replace method use forward slash characters to enclose the first argument?
        Posted  
        
            by 
                Phillip Dodd
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Phillip Dodd
        
        
        
        Published on 2012-06-09T22:38:09Z
        Indexed on 
            2012/06/09
            22:40 UTC
        
        
        Read the original article
        Hit count: 314
        
JavaScript
|syntax
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.
© Stack Overflow or respective owner