Get all object properties from an array of objects





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm attempting to create a material cut list from input entered by a user in a Google Sheets. I'm not receiving any errors except for the last part, where I try to loop over an array of objects and use the objects values to replace the text on a Google Doc. By invoking Object.value() the following error is thrown.




TypeError: Cannot find function value in object function Object() { [native code for Object.Object, arity=1] }.




I've tried using other object methods, but Object.value() is the only one that allows me to get the actual values from jambObj.



//Create jamb cut list
function jambsCutList() {
var numberOfJambCuts;
var sizeOfJambCuts;
var jambOpenings;
var jambs = 1;
var jambObj = {};
var jambArr = ;

//Loop through the first three google sheet colums
for(var i = 5; i < values.length; i++) {
numberOfJambCuts = values[i][0];
sizeOfJambCuts = values[i][1];
jambOpenings = values[i][2];

jambObj = {cuts: numberOfJambCuts, size: sizeOfJambCuts, openings:
jambOpenings};
jambArr.push(jambObj);
}

//Sort jambArr from largest cut size to smallest
jambArr.sort(function(a, b) {
return parseInt(b.size) - parseInt(a.size);
});

//Problem Code
//Loop through an array of objects and print all properties to the doc
for (var j = 0; j < jambArr.length; j++){
body.replaceText('##jambs' + jambs + '##', Object.value(jambArr[j]))
jambs += 1;
}
}









share|improve this question

























  • Object.value? Link documentation on such method.

    – TheMaster
    Nov 16 '18 at 22:35






  • 1





    Unfortunately, Object.values() cannot be used at Google Apps Script yet. So how about using Object.keys(jambArr[j]).map(function(e){return jambArr[j][e]}) instead of Object.value(jambArr[j])? But I'm not sure whether the result of modified body.replaceText() is what you want. If the result was not what you want, can you provide the detail information about the result you want?

    – Tanaike
    Nov 16 '18 at 22:37






  • 1





    Yes, Object.values() does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?

    – Dustin Michels
    Nov 16 '18 at 23:10




















0















I'm attempting to create a material cut list from input entered by a user in a Google Sheets. I'm not receiving any errors except for the last part, where I try to loop over an array of objects and use the objects values to replace the text on a Google Doc. By invoking Object.value() the following error is thrown.




TypeError: Cannot find function value in object function Object() { [native code for Object.Object, arity=1] }.




I've tried using other object methods, but Object.value() is the only one that allows me to get the actual values from jambObj.



//Create jamb cut list
function jambsCutList() {
var numberOfJambCuts;
var sizeOfJambCuts;
var jambOpenings;
var jambs = 1;
var jambObj = {};
var jambArr = ;

//Loop through the first three google sheet colums
for(var i = 5; i < values.length; i++) {
numberOfJambCuts = values[i][0];
sizeOfJambCuts = values[i][1];
jambOpenings = values[i][2];

jambObj = {cuts: numberOfJambCuts, size: sizeOfJambCuts, openings:
jambOpenings};
jambArr.push(jambObj);
}

//Sort jambArr from largest cut size to smallest
jambArr.sort(function(a, b) {
return parseInt(b.size) - parseInt(a.size);
});

//Problem Code
//Loop through an array of objects and print all properties to the doc
for (var j = 0; j < jambArr.length; j++){
body.replaceText('##jambs' + jambs + '##', Object.value(jambArr[j]))
jambs += 1;
}
}









share|improve this question

























  • Object.value? Link documentation on such method.

    – TheMaster
    Nov 16 '18 at 22:35






  • 1





    Unfortunately, Object.values() cannot be used at Google Apps Script yet. So how about using Object.keys(jambArr[j]).map(function(e){return jambArr[j][e]}) instead of Object.value(jambArr[j])? But I'm not sure whether the result of modified body.replaceText() is what you want. If the result was not what you want, can you provide the detail information about the result you want?

    – Tanaike
    Nov 16 '18 at 22:37






  • 1





    Yes, Object.values() does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?

    – Dustin Michels
    Nov 16 '18 at 23:10
















0












0








0








I'm attempting to create a material cut list from input entered by a user in a Google Sheets. I'm not receiving any errors except for the last part, where I try to loop over an array of objects and use the objects values to replace the text on a Google Doc. By invoking Object.value() the following error is thrown.




TypeError: Cannot find function value in object function Object() { [native code for Object.Object, arity=1] }.




I've tried using other object methods, but Object.value() is the only one that allows me to get the actual values from jambObj.



//Create jamb cut list
function jambsCutList() {
var numberOfJambCuts;
var sizeOfJambCuts;
var jambOpenings;
var jambs = 1;
var jambObj = {};
var jambArr = ;

//Loop through the first three google sheet colums
for(var i = 5; i < values.length; i++) {
numberOfJambCuts = values[i][0];
sizeOfJambCuts = values[i][1];
jambOpenings = values[i][2];

jambObj = {cuts: numberOfJambCuts, size: sizeOfJambCuts, openings:
jambOpenings};
jambArr.push(jambObj);
}

//Sort jambArr from largest cut size to smallest
jambArr.sort(function(a, b) {
return parseInt(b.size) - parseInt(a.size);
});

//Problem Code
//Loop through an array of objects and print all properties to the doc
for (var j = 0; j < jambArr.length; j++){
body.replaceText('##jambs' + jambs + '##', Object.value(jambArr[j]))
jambs += 1;
}
}









share|improve this question
















I'm attempting to create a material cut list from input entered by a user in a Google Sheets. I'm not receiving any errors except for the last part, where I try to loop over an array of objects and use the objects values to replace the text on a Google Doc. By invoking Object.value() the following error is thrown.




TypeError: Cannot find function value in object function Object() { [native code for Object.Object, arity=1] }.




I've tried using other object methods, but Object.value() is the only one that allows me to get the actual values from jambObj.



//Create jamb cut list
function jambsCutList() {
var numberOfJambCuts;
var sizeOfJambCuts;
var jambOpenings;
var jambs = 1;
var jambObj = {};
var jambArr = ;

//Loop through the first three google sheet colums
for(var i = 5; i < values.length; i++) {
numberOfJambCuts = values[i][0];
sizeOfJambCuts = values[i][1];
jambOpenings = values[i][2];

jambObj = {cuts: numberOfJambCuts, size: sizeOfJambCuts, openings:
jambOpenings};
jambArr.push(jambObj);
}

//Sort jambArr from largest cut size to smallest
jambArr.sort(function(a, b) {
return parseInt(b.size) - parseInt(a.size);
});

//Problem Code
//Loop through an array of objects and print all properties to the doc
for (var j = 0; j < jambArr.length; j++){
body.replaceText('##jambs' + jambs + '##', Object.value(jambArr[j]))
jambs += 1;
}
}






object google-apps-script






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 20 at 20:55









pnuts

49.3k764101




49.3k764101










asked Nov 16 '18 at 22:01









AndyHarbinAndyHarbin

1




1













  • Object.value? Link documentation on such method.

    – TheMaster
    Nov 16 '18 at 22:35






  • 1





    Unfortunately, Object.values() cannot be used at Google Apps Script yet. So how about using Object.keys(jambArr[j]).map(function(e){return jambArr[j][e]}) instead of Object.value(jambArr[j])? But I'm not sure whether the result of modified body.replaceText() is what you want. If the result was not what you want, can you provide the detail information about the result you want?

    – Tanaike
    Nov 16 '18 at 22:37






  • 1





    Yes, Object.values() does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?

    – Dustin Michels
    Nov 16 '18 at 23:10





















  • Object.value? Link documentation on such method.

    – TheMaster
    Nov 16 '18 at 22:35






  • 1





    Unfortunately, Object.values() cannot be used at Google Apps Script yet. So how about using Object.keys(jambArr[j]).map(function(e){return jambArr[j][e]}) instead of Object.value(jambArr[j])? But I'm not sure whether the result of modified body.replaceText() is what you want. If the result was not what you want, can you provide the detail information about the result you want?

    – Tanaike
    Nov 16 '18 at 22:37






  • 1





    Yes, Object.values() does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?

    – Dustin Michels
    Nov 16 '18 at 23:10



















Object.value? Link documentation on such method.

– TheMaster
Nov 16 '18 at 22:35





Object.value? Link documentation on such method.

– TheMaster
Nov 16 '18 at 22:35




1




1





Unfortunately, Object.values() cannot be used at Google Apps Script yet. So how about using Object.keys(jambArr[j]).map(function(e){return jambArr[j][e]}) instead of Object.value(jambArr[j])? But I'm not sure whether the result of modified body.replaceText() is what you want. If the result was not what you want, can you provide the detail information about the result you want?

– Tanaike
Nov 16 '18 at 22:37





Unfortunately, Object.values() cannot be used at Google Apps Script yet. So how about using Object.keys(jambArr[j]).map(function(e){return jambArr[j][e]}) instead of Object.value(jambArr[j])? But I'm not sure whether the result of modified body.replaceText() is what you want. If the result was not what you want, can you provide the detail information about the result you want?

– Tanaike
Nov 16 '18 at 22:37




1




1





Yes, Object.values() does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?

– Dustin Michels
Nov 16 '18 at 23:10







Yes, Object.values() does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?

– Dustin Michels
Nov 16 '18 at 23:10














1 Answer
1






active

oldest

votes


















1














As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.



Replace



Object.value(jambArr[j])


with



Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346016%2fget-all-object-properties-from-an-array-of-objects%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.



    Replace



    Object.value(jambArr[j])


    with



    Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")





    share|improve this answer




























      1














      As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.



      Replace



      Object.value(jambArr[j])


      with



      Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")





      share|improve this answer


























        1












        1








        1







        As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.



        Replace



        Object.value(jambArr[j])


        with



        Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")





        share|improve this answer













        As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.



        Replace



        Object.value(jambArr[j])


        with



        Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 '18 at 14:22









        Amit AgarwalAmit Agarwal

        5,63711326




        5,63711326
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346016%2fget-all-object-properties-from-an-array-of-objects%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine