Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to push array object name javascript

function getKeyValue(object) {
    return Object.keys(object).reduce(function (result, key) {
        return result.concat(
            object[key] && typeof object[key] === 'object' ?
            getKeyValue(object[key]) :
            [[key, object[key]]]
        );
    }, []);
}

var data = { id: 23, name: "Jacob", link: { rel: "self", link: "www.abc.com", }, company: { data: { id: 1, ref: 324 } } };

console.log(getKeyValue(data));
Comment

PREVIOUS NEXT
Code Example
Javascript :: nvm use a particular version 
Javascript :: !! js 
Javascript :: catch status code 403 in fetch 
Javascript :: send request express 
Javascript :: structure data in javascript 
Javascript :: require vs import 
Javascript :: class 
Javascript :: module imports as default 
Javascript :: javascript array slice() example 
Javascript :: bottom navigation bar react native hide on keyboard 
Javascript :: web storage api 
Javascript :: reducer react 
Javascript :: Remove all falsy values from an array 
Javascript :: numbers split 
Javascript :: try without catch 
Javascript :: js code for webpage download progress bar 
Javascript :: react functional component 
Javascript :: google js console 
Javascript :: delete item from array of objects javascript 
Javascript :: Creating New Block for blockchain 
Javascript :: JS how to access a class propert 
Javascript :: get item in array from index 
Javascript :: mongoose create text index to search for text 
Javascript :: update data in sequelize 
Javascript :: js use await in synchronous method 
Javascript :: javascript this keyword 
Javascript :: vuejs jwt authentication example 
Javascript :: short-circuit evaluation javascript 
Javascript :: how to make pdf of web page 
Javascript :: javascript syntax of throw statement 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =