Salesforce Fact #827 | Adding object in middle in LWC array of objects

In LWC, Many times we deal with the scenario of adding an object conditionally in JS array of objects. And it needs to be added in the middle based on some condition.

In this case the spread operator and the ternary operator combo works together.

Reference: https://stackoverflow.com/questions/70385371/js-conditionally-adding-adding-in-the-middle-of-an-array

Attached is an example screenshot.




Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow