Welcome to
On Feet Nation
smithmorgan Online
Cassie M. Stephens Online
asimseo Online
basitkhatr6666 Online
Andrew Online
Brenda Online
Posted by smithmorgan on October 19, 2024 at 3:41pm 0 Comments 0 Likes
Posted by smithmorgan on October 19, 2024 at 3:41pm 0 Comments 0 Likes
ES6 introduced many new methods built into the Array prototype. These methods allow you to interact with the data in your arrays in different ways, like transforming each item (map), sorting an array, or filtering an array. My favorite array methods that I use commonly in Vue apps are filter, map, forEach, and includes. Here’s an example using filter:
computed: {
// Without "filter" functional array method
oldFilteredItems() {
const filtered = []
for (const item in this.items) {
if(item.value > 10) {
filtered.push(item)
}
}
return filtered
},
// With "filter" functional array method
filteredItems() {
return this.items.filter((item) => item.value > 10)
}
}
This reduces the code we have to write (and read!) from seven lines to only one!
Read more: https://itmaster-soft.com/en/vue-js-development-services
© 2024 Created by PH the vintage. Powered by
You need to be a member of On Feet Nation to add comments!
Join On Feet Nation