首页 > 试题广场 >

1.下面哪个语句的执行结果与 '1.2.3'.split('

[单选题]
1.下面哪个语句的执行结果与 '1.2.3'.split('') 相同
  • '1.2.3'.split(/(\.)/)
  • '1.2.3'.split(/(.)/)
  • '1.2.3'.split(/(?:\.)/)
  • '1.2.3'.split(/(?:.)/)

参考:MDN: String.prototype.split()

If separator is a regular expression that contains capturing parentheses, then each time separator i***atched, the results (including any undefined results) of the capturing parentheses are spliced into the output array.

发表于 2019-05-19 19:41:00 回复(0)
C选项中,?:表示不应该捕获匹配到的内容,所以结果中不会出现点,只有1,2,3,与题目要求不符
发表于 2020-03-17 14:21:27 回复(0)