gpt4 book ai didi

JavaScript: `new RegExp(' hi' )` versus ` RegExp ('hi' )`?

转载 作者:行者123 更新时间:2023-11-30 08:30:08 28 4
gpt4 key购买 nike

RegExp('hi') 和有什么区别和new RegExp('hi')

new 是吗?关键字在这里做什么?

最佳答案

完全相同

The RegExp constructor is the %RegExp% intrinsic object and the initial value of the RegExp property of the global object. When RegExp is called as a function rather than as a constructor, it creates and initializes a new RegExp object. Thus the function call RegExp(…) is equivalent to the object creation expression new RegExp(…) with the same arguments.

来自http://www.ecma-international.org/ecma-262/6.0/#sec-regexp-constructor

关于JavaScript: `new RegExp(' hi' )` versus ` RegExp ('hi' )`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39215710/

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