mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2024-04-21 12:32:22 +00:00
docs(object): edit object
This commit is contained in:
+2
-2
@@ -1191,7 +1191,7 @@ let emptyObject = { ...null, ...undefined }; // 不报错
|
||||
let aWithXGetter = {
|
||||
...a,
|
||||
get x() {
|
||||
throws new Error('not thrown yet');
|
||||
throw new Error('not throw yet');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1200,7 +1200,7 @@ let runtimeError = {
|
||||
...a,
|
||||
...{
|
||||
get x() {
|
||||
throws new Error('thrown now');
|
||||
throw new Error('throw now');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -367,7 +367,7 @@ JavaScript 语言的正则表达式,只支持先行断言(lookahead)和先
|
||||
/\d+(?!%)/.exec('that’s all 44 of them') // ["44"]
|
||||
```
|
||||
|
||||
上面两个字符串,如果互换正则表达式,就会匹配失败。另外,还可以看到,”先行断言“括号之中的部分(`(?=%)`),是不计入返回结果的。
|
||||
上面两个字符串,如果互换正则表达式,就不会得到相同结果。另外,还可以看到,”先行断言“括号之中的部分(`(?=%)`),是不计入返回结果的。
|
||||
|
||||
“后行断言”正好与“先行断言”相反,`x`只有在`y`后面才匹配,必须写成`/(?<=y)x/`。比如,只匹配美元符号之后的数字,要写成`/(?<=\$)\d+/`。”后行否定断言“则与”先行否定断言“相反,`x`只有不在`y`后面才匹配,必须写成`/(?<!y)x/`。比如,只匹配不在美元符号后面的数字,要写成`/(?<!\$)\d+/`。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user