Skip to content

Instantly share code, notes, and snippets.

Avatar

Emilio Rios emilioriosvz

View GitHub Profile
@emilioriosvz
emilioriosvz / getTypes.js
Last active Jun 29, 2017
function that receive an object and change the values by the type of the key
View getTypes.js
var o = {
'1': 'adios',
'2': 1.5,
'3': true,
'4': [1, 2, 3],
'5': {1: 2}
}
const getTypes = obj => {
return Object.keys(obj).reduce((prev, key) => {
@emilioriosvz
emilioriosvz / getAllPropertiesNames.js
Created Mar 14, 2016
Get all properties names of an object
View getAllPropertiesNames.js
var getAllProperties = function (object) {
var properties = []
do {
Object.getOwnPropertyNames(object).forEach((prop) => {
if (!~properties.indexOf(prop)) {
properties.push(prop)
}
})
} while (object = Object.getPrototypeOf(object))