所以我在调试工作中的一些奇怪事件时偶然发现了这一点,其中字符串在文本中包含“null”:
"Some string containing testnull in the text".replace(null, "REPLACER")
"> Some string containing testREPLACER in the text"
尽管
"Some string containing testnull in the text".replace(undefined, "REPLACER")
"> Some string containing testnull in the text"