It's crucial for any JavaScript developer to know how to efficiently work with JSON data. If you work with UI5/ Fiori you are certainly going to consume JSON data (an array of objects) in your frontend application.
So, to help with that, I've uploaded this video tutorial that runs through a small set of JavaScript array methods that you can use to create, update or loop through JSON data in your application.
The array methods that are covered include:
- Add a new object at the start - unshift()
- Add a new object at the end - push()
- Add a new object in the middle - splice()
- Looping through an array of objects:
- Find an object in an array by its values - find()
- Get multiple items in an array that match a condition - filter()
- Transform objects of an array - map()
- Add a property to every object of an array - forEach()
- Sorting an array by a property - sort()
- Check if objects in an array fulfill a specific condition -some(), every()
It's also important to note that I've used
ES6 syntax in all of the examples.
If you have any questions please feel free to comment and I'll help where I can
🙂
Thanks for reading!
B