I'm calling my api that returning a json in the response. I'm calling as below:
getAllLearn() {
this.learnService.getAllLearn().subscribe(res =>{
// in result of log is I have res.featured which has only one index (0)
console.log(res);
this.myvar = res.featured;
})
}
Then I add this code to the end:
this.myvar[1] = res.featured[0];
Then in console log I get 2 indexes (0,1). Why does this happen? (I know the built in console.log has some problems but really can not understand this)
Finally my code is:
getAllLearn() {
this.learnService.getAllLearn().subscribe(res =>{
// ---- Now it contains two indexes in my res.featured -----
console.log(res);
this.featured2 = res.featured;
this.featured2[1] = res.featured[0];
})
}