gpt4 book ai didi

Javascript String.replace() ,结果不明确

转载 作者:行者123 更新时间:2023-11-29 22:25:51 25 4
gpt4 key购买 nike

查看我的代码

<html>
<body>

<script type="text/javascript">

var str="Visit Microsoft!";

document.write( str = str.replace("",'ss'));

</script>
</body>
</html>

输出是

 ssVisit Microsoft!

为什么会这样?

最佳答案

这是正确的,因为每个字符串都以空字符串开头。有关详细信息,请参阅以下帖子:

Why does "abcd".StartsWith("") return true?

关于Javascript String.replace() ,结果不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9419748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com