javascript - ToString() and .replace in one line? -


is possible combine these 2 lines of code one?

meaning, can tostring() , .replace() in 1 line?

var mysecondvar = myfirstvar.tostring() mysecondvar = mysecondvar.replace("a","u"); 

yes, can chain methods.

myfirstvar.tostring().replace('a', 'u') 

note:

  1. tostring should tostring
  2. string#replace replace first occurrence of string. replace occurrences use replace regex

Comments