📌  相关文章
📜  如何推送数组对象名称 javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:01.880000             🧑  作者: Mango

代码示例1
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));