Skip to content

Commit 639b798

Browse files
alexreardonilyavolodin
authored andcommitted
Docs: Use Object.prototype in examples (#7755)
* Update: using Object.prototype for no-prototype-builtins example * Update: adding usages of Object.prototype and Array.prototype to docs
1 parent 9679daa commit 639b798

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

docs/rules/guard-for-in.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Examples of **correct** code for this rule:
3030
/*eslint guard-for-in: "error"*/
3131

3232
for (key in foo) {
33+
if (Object.prototype.hasOwnProperty.call(foo, key)) {
34+
doSomething(key);
35+
}
3336
if ({}.hasOwnProperty.call(foo, key)) {
3437
doSomething(key);
3538
}

docs/rules/no-extra-parens.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Examples of **correct** code for this rule with the default `"all"` option:
4747

4848
(0).toString();
4949

50+
(Object.prototype.toString.call());
51+
5052
({}.toString.call());
5153

5254
(function(){}) ? a() : b();
@@ -121,6 +123,8 @@ Examples of **correct** code for this rule with the `"functions"` option:
121123

122124
(0).toString();
123125

126+
(Object.prototype.toString.call());
127+
124128
({}.toString.call());
125129

126130
(function(){} ? a() : b());

docs/rules/no-prototype-builtins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ Examples of **correct** code for this rule:
2323
```js
2424
/*eslint no-prototype-builtins: "error"*/
2525

26-
var hasBarProperty = {}.hasOwnProperty.call(foo, "bar");
26+
var hasBarProperty = Object.prototype.hasOwnProperty.call(foo, "bar");
2727

28-
var isPrototypeOfBar = {}.isPrototypeOf.call(foo, bar);
28+
var isPrototypeOfBar = Object.prototype.isPrototypeOf.call(foo, bar);
2929

3030
var barIsEnumerable = {}.propertyIsEnumerable.call(foo, "bar");
3131
```

docs/rules/prefer-rest-params.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ function foo() {
1818
console.log(arguments);
1919
}
2020

21+
function foo(action) {
22+
var args = Array.prototype.slice.call(arguments, 1);
23+
action.apply(null, args);
24+
}
25+
2126
function foo(action) {
2227
var args = [].slice.call(arguments, 1);
2328
action.apply(null, args);

0 commit comments

Comments
 (0)