Answer the question
In order to leave comments, you need to log in
Why does filter work for an object, what does it do?
Understanding the creepy Vue Isotope plugin.
Here is what is used to filter elements:
filter: function (key) {
this.$refs.cpt.filter(key)
}
this.$refs.cpt
's an object, not an array. I can't figure out what's going on, what is this code doing?
Answer the question
In order to leave comments, you need to log in
Apparently, because the plugin's source code has its own filter
function. Speaking
of the possibility of using array methods on objects. Here is the code that works great:
const obj = {
'0': 'some value 0',
'1': 'some value 1',
'2': false,
length: 3,
};
const filteredArr = Array.prototype.filter.call(obj, el => el);
console.log(filteredArr); // ["0 value", "1 value"]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question