push at first index typescript
var a = [23, 45, 12, 67];
a.unshift(34);
console.log(a); // [34, 23, 45, 12, 67]
push at first index typescript
var a = [23, 45, 12, 67];
a.unshift(34);
console.log(a); // [34, 23, 45, 12, 67]
how to add new index in array in typescript
let currentDate = formatDate(new Date(), 'MM/dd/yyyy', 'en');
let objPurchare=new PurchaseOrderLineItems();
objPurchare.Id=obj.Id;
objPurchare.ItemNo=obj.ItemNo+1;
objPurchare.MultiReleaseNo=obj.MultiReleaseNo+1;
objPurchare.DateCreated=obj.DateCreated;
objPurchare.Partno=obj.Partno;
objPurchare.OnHold=obj.OnHold;
objPurchare.Description=obj.Description;
objPurchare.Supplier=obj.Supplier;
objPurchare.LastPurchase=obj.LastPurchase;
objPurchare.OrderQty=0;
objPurchare.Demand=obj.Demand;
objPurchare.AvgUsage=parseFloat(obj.AvgUsage).toFixed(4);
objPurchare.LeadTime=obj.LeadTime;
objPurchare.OnHand=obj.OnHand;
objPurchare.PromiseDate= this.datePipe.transform(obj.PromiseDate, 'yyyy-MM-dd'),
objPurchare.Notes=obj.Notes;
objPurchare.Checked=false;
objPurchare.ApplyRedClass=formatDate(obj.DateCreated, 'MM/dd/yyyy', 'en') < currentDate ? true : false;
objPurchare.BuyerId= obj.BuyerId;
objPurchare.MultiRelease=0;
objPurchare.Addbtn= true;
objPurchare.IsMultiRelease=false;
const insert = (arr, index, newItem) => [
// part of the array before the specified index
...arr.slice(0, index),
// inserted item
newItem,
// part of the array after the specified index
...arr.slice(index)
]
this.reOrderQueueList[i].MultiReleaseLineItems=insert(this.reOrderQueueList[i].MultiReleaseLineItems, j+1, objPurchare)
let counter=1;
for (let x = 0; x < this.reOrderQueueList[i].MultiReleaseLineItems.length; x++) {
this.reOrderQueueList[i].MultiReleaseLineItems[x].ItemNo=counter;
this.reOrderQueueList[i].MultiReleaseLineItems[x].MultiReleaseNo=counter;
counter++
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us