Last active
December 24, 2025 08:25
-
-
Save ritacse/be991c6fed3e759d5b000a6a2822891f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ~~~~~ jQuery.map( object, callback ) | |
| //The function to process each item against. The first argument to the function is the array item, | |
| //the second argument is the index in array the function can return any value. A returned array will be flattened into the resulting array. | |
| o.LCItemList = ItemDetails.map(item => { | |
| return { | |
| childID: item.childID, | |
| itemID: item.itemID, | |
| quantity: item.quantity, | |
| unitPrice: item.unitPrice, | |
| isDelete: item.isDelete | |
| }; | |
| }); | |
| // LCItemList Array will be generated form each item of ItemDetails array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //https://www.geeksforgeeks.org/javascript-get-the-index-of-an-object-by-its-property/ | |
| let arrayObj = [{ | |
| prop_1: 'val', | |
| prop_2: 'val_12', | |
| prop_3: 'val_13' | |
| }, { | |
| prop_1: 'val', | |
| prop_2: 'val_22', | |
| prop_3: 'val_23' | |
| }]; | |
| function GFG_Fun() { | |
| let prop = 'prop_2'; | |
| let val = 'val_22'; | |
| console.log("Index of prop = "+ prop + " val = " + val +" is = " + | |
| arrayObj.map(function (e) { | |
| return e.prop_2; | |
| }).indexOf(val)); | |
| } | |
| GFG_Fun(); | |
| //Output | |
| Index of prop = prop_2 val = val_22 is = 1 | |
| //Ral example: | |
| _.map(PIItemDetails, function (obj) { | |
| var index = PIItemDetails.map(function (e) { return e.itemDescription; }).indexOf(obj.itemDescription); // here is the index | |
| obj.serial = index + 1; | |
| obj.totalAvgWeight = (obj.piQty * obj.avgWeightKGPerUnit); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log(o); | |
| const propertyCount = Object.keys(o.GRNChild).length; | |
| const jsonSize = JSON.stringify(o.GRNChild).length; | |
| console.log("Number of Child properties: " + propertyCount, "Approximate memory size: " + jsonSize / 10000); | |
| const propertyCount2 = Object.keys(o).length; | |
| const jsonSize2 = JSON.stringify(o).length; | |
| console.log("Number of Object properties: " + propertyCount2, "Approximate memory size: " + jsonSize2 / 10000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var n = 9; | |
| n = String(n).padStart(2, '0'); //"09" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Sorting both ascending & descending way on numeric columns | |
| TransactionDetails = TransactionDetails.sort(function (a, b) { | |
| // Column 1 (descending) | |
| if (a.POBalance < b.POBalance) return 1; | |
| if (a.POBalance > b.POBalance) return -1; | |
| // Column 2 (ascending) | |
| if (a.purchaseIndentID < b.purchaseIndentID) return -1; | |
| if (a.purchaseIndentID > b.purchaseIndentID) return 1; | |
| return 0; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment