Skip to content

Instantly share code, notes, and snippets.

@jakubbarczyk
Created December 23, 2017 13:05
Show Gist options
  • Save jakubbarczyk/e9a72d0f102da00fdda0a44bbe94b301 to your computer and use it in GitHub Desktop.
Save jakubbarczyk/e9a72d0f102da00fdda0a44bbe94b301 to your computer and use it in GitHub Desktop.
Utility function that maps object's own property types.
function getOwnPropertyTypes(val) {
'use strict';
if (val && typeof val === 'object') {
return Object.getOwnPropertyNames(val)
.reduce((obj, key) => Object.defineProperty(obj, key, { value: typeof val[key] }), {})
}
return {};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment