Replace With Empty String In Javascript Method Vs Function