Getting an array of certain objects within an object I'm trying to get an array of all "form" objects within a large "masterFormObject" object. Is this the cleanest way to do so, or is there a better way I can check if the form objects themselves are not undefined directly and check both the applicant and account portion of this form object without having two separate blocks of undefined checks / forEach loops?

vm.getAllForms = function (type) {

  var allForms = [];
  var accountForms = [];
  var applicantForms = [];

  if (undefined != vm.masterFormObject) {
    if (undefined != vm.masterFormObject.payload) {
      if (undefined != vm.masterFormObject.payload.accounts) {
        vm.masterFormObject.payload.accounts.forEach(function (account) {
          if (undefined != account.Forms) {

            account.Forms.forEach(function (Form) {

              allForms.push(Form);
              accountForms.push(Form);

            });
          }
        });
      }

      if (undefined != vm.masterFormObject.payload.accounts) {
        vm.masterFormObject.payload.applicants.forEach(function (applicant) {
          if (undefined != applicant.Forms) {
            applicant.Forms.forEach(function (Form) {
              allForms.push(Form);
              applicantForms.push(Form);
            });
          }
        });
      }
    }
  }
Your nested "ifs" make the code very hard to read.  I would think about changing your approach to something like

if (undefined === vm.masterFormObject) {
    console.log('Some error message.');
    return;
}
if (undefined === vm.masterFormObject.payload) {
    console.log('Some other message');
    return;
}
// and so on

// or if inside a loop
if (undefined === account.Forms) {
    console.log('Some error message.');
    // continue to next iteration
    continue;
}