Created
December 23, 2017 13:05
-
-
Save jakubbarczyk/e9a72d0f102da00fdda0a44bbe94b301 to your computer and use it in GitHub Desktop.
Utility function that maps object's own property types.
This file contains hidden or 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
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