Skip to content

Instantly share code, notes, and snippets.

@onionmk2
Last active December 6, 2016 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onionmk2/895879d0a6a2fe2b6ec28b636fc809cc to your computer and use it in GitHub Desktop.
Save onionmk2/895879d0a6a2fe2b6ec28b636fc809cc to your computer and use it in GitHub Desktop.
prototypeにはえてるプロパティをenumrableなものも取りたいときの方法
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));
@onionmk2
Copy link
Author

onionmk2 commented Dec 4, 2016

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties

Enumerableをとるか、prototype chainからとるか が一覧になっててわかりやすい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment