Last active
December 6, 2016 14:42
-
-
Save onionmk2/895879d0a6a2fe2b6ec28b636fc809cc to your computer and use it in GitHub Desktop.
prototypeにはえてるプロパティをenumrableなものも取りたいときの方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fs = require('fs'); | |
function log(targat) { | |
const target = targat.prototype; | |
const fileName = __dirname + '/dist/' + target.constructor.name + '.txt'; | |
const props = Object.getOwnPropertyDescriptors(target); | |
const str = Object.keys(props).join('\n'); | |
fs.createWriteStream(fileName).write(str); | |
} | |
[Array, RegExp, Object, String, Error, Set, Map, Promise].forEach( target => log(target)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties
Enumerableをとるか、prototype chainからとるか が一覧になっててわかりやすい