0

My Code:

export class AppComponent implements OnInit {
 public manipulate: any ;
 ...
 this.results.forEach(result => {
   var index = result.date_value;
   if (!this.manipulate.hasOwnProperty(index)) {
     this.manipulate.{index} = [];
   }
   this.manupulate.{index}.push(result);
 });
}

Expected Result:

this.manupulate = {
  20171001 : [
     0: { resultset },
     ...
  ]
}

How to write the program. If I use Array the browser handed. the reason is a high range of the index value.

The below javascript code is run perfectly.

manupulate[20171001] = 
  [
     0: { resultset },
     ...
  ]
}

If I use typescript the browser handed.

this.manupulate[20171001] = 
  [
     0: { resultset },
     ...
  ]
}

Thanks for all.

1
  • 1
    try this : this.manupulate[index].push(result); Commented Oct 6, 2017 at 13:53

1 Answer 1

1

Try this :

use this.manupulate[index].push(result); instead of this.manupulate.{index}.push(result);

if (!this.manipulate.hasOwnProperty(index)) {
    this.manipulate[index] = [];
}
this.manupulate[index].push(result);
Sign up to request clarification or add additional context in comments.

3 Comments

I tried but the system is handed due to index value is large input. Ex: 20171003 this is large value it's hand the browser. Please try below code: this.manupulate[20171003]=10;
@BalasubramaniSamiyappan Are you initializing your object? public manipulate: any = {}
My Initialization mistake: public manipulate: any = [] this is wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.