admin管理员组文章数量:1317909
I find a point:
var example = /1/._ ;
It can be accept by the interpreter of chrome or Firefox ,and it always return undefined
.
But I don't understand why, is ._
a special usage in regular expression? Or is there something else I don't know?
I have searched in Google, but get nothing.
I find a point:
var example = /1/._ ;
It can be accept by the interpreter of chrome or Firefox ,and it always return undefined
.
But I don't understand why, is ._
a special usage in regular expression? Or is there something else I don't know?
I have searched in Google, but get nothing.
Share Improve this question edited Aug 24, 2013 at 10:56 Denys Séguret 383k90 gold badges810 silver badges775 bronze badges asked Aug 24, 2013 at 10:39 kamiakamia 314 bronze badges 02 Answers
Reset to default 11_
is a valid name for a property :
IdentifierStart ::
UnicodeLetter
$
_
\ UnicodeEscapeSequence
As there is no property with this name, you just get undefined
. There's nothing specific to regular expression here : there's rarely a property with this name unless you define it or import underscore.js (then it's not on regexes, just on window
).
You would have get the same result with
var example = /1/.abracadabra;
or
var example = ({}).π;
Let's break it down:
var example = /1/ . _;
^ regex object ^ dot (meaning, accessing a method of a property) ^ attempt to access a property named "_".
Since _
is a property that doesn't exist, you'll get undefined
every time.
Much like you would with
var example = document.somethingThatDoesntExist;
本文标签: What doesmean in javascriptStack Overflow
版权声明:本文标题:What does ._ mean in javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741998738a2410575.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论