This is my object (made sure it's a typeof object):
{
"1": {"user_id":1,"test":"","user_name":"potato0","isok":"true"},
"2":{"user_id":2,"test":"","user_name":"potato1","isok":" true"},
"3":{"user_id":3,"test":"","user_name":"potato2","isok":" true"},
"4":{"user_id":4,"test":"","user_name":"potato3","isok":"locationd"}
}
Why using .filter
doesn't work for me?
Is it because my variable is typeof object
and the method works only with arrays?
this.activeUsers = window.users.filter( function(user) {
// return ( (user.test === '0') && (user.isok === '0') );
return user.user_id === 1;
});
getting the error:
.filter is not a function
What is the suggested alternative with objects?