Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f4242a5

Browse files
Add propertyIsEnumerable example
1 parent 1f21acd commit f4242a5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>propertyIsEnumerable Example</title>
6+
<link rel="stylesheet" href="http://code-warrior.github.io/styles/reset.css">
7+
<link rel="stylesheet" href="http://code-warrior.github.io/styles/base.css">
8+
</head>
9+
<body>
10+
<h1><code>propertyIsEnumerable</code> Example</h1>
11+
<p>Open your console to see this program’s output from the file <a href="propertyIsEnumerable.js">propertyIsEnumerable.js</a></p>
12+
<script src="propertyIsEnumerable.js"></script>
13+
</body>
14+
</html>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*jslint es6, single, devel, for */
2+
/*eslint no-console: ["error", { allow: ["log"] }] */
3+
4+
'use strict';
5+
6+
let dog = {
7+
adoptable: true,
8+
vaccinated: true
9+
};
10+
11+
Object.defineProperty(dog, `name`, {
12+
value: `Spot`,
13+
enumerable: false
14+
});
15+
16+
console.log(dog.propertyIsEnumerable(`adoptable`)); // true
17+
console.log(dog.propertyIsEnumerable(`vaccinated`)); // true
18+
console.log(dog.propertyIsEnumerable(`name`)); // false
19+
console.log(`Please adopt ${dog.name}. He’s...`);
20+
21+
for (let property in dog) {
22+
console.log(`— ${property}`);
23+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /