How to loop through JSON Object using JQuery

Sometimes you get into a need where you need to loop through a JSON object while using JQuery or Angular 6 (with typescript). This is become very useful when you are not fully aware of what is the JSON object has in term of properties but you still needs to do some operations on the object properties..
So Let’s assume that you have a JSON Object called employee and you need to print the keys and values of these keys:

var employee = {
firstName: "FName",
lastName: "LName"

var keys = Object.keys(employee);

for (var i = 0; i < keys.length; i++) {
    console.log(keys[i]]); /*printing the key, so it will be firstName and lastName */
   console.log(employee[keys[i]]); /*printing the values; which will be FName and LName */

Note: This syntax is working fine with Angular 6 while using Type Script and with JQuery.

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed – JavaScript heap out of memory

Recently I faced a strange issue where I’m not being able to compile my Angular 7.0+ application because of the below error message

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::DecodeWrite
2: node_module_register
3: v8::internal::FatalProcessOutOfMemory
4: v8::internal::FatalProcessOutOfMemory
5: v8::internal::Heap::MaxHeapGrowingFactor
6: v8::internal::Factory::NewJSPromise
7: v8::internal::interpreter::operator<<
8: v8::internal::NativesCollection<0>::GetScriptsSource
9: v8::internal::NativesCollection<0>::GetScriptsSource
10: v8::internal::NativesCollection<0>::GetScriptsSource
11: 00000044D2784281

I tried to upgrade the nodeJs and Angular version for my app but with no luck. I even tried to increase the RAMs on my development PC and that didn’t solve the issue.
In order to solve this issue, you will need to adjust the default nodeJs used spaces by using the following command:

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod --build-optimizer

Below is the original command that I was using and it was giving me the error in concern

ng build --prod --prod-optimizer