I'm trying to compare two objects with underscore.
Object 1 (Filter)
{
"tuxedoorsuit":"tuxedoorsuit-tuxedo",
"occasions":"occasions-wedding"
}
Object 2 (Properties)
{
"tuxedoorsuit":"tuxedoorsuit-tuxedo",
"occasions":"occasions-wedding",
"occasions":"occasions-prom",
"product_fit":"product_fit-slim",
"colorfamily":"colorfamily-black"
}
I want to return true when all items of Object 1 are found within Object 2. What would be the best underscore method to use for this?
isMatchwould be far better. But actually it's interesting to note that it won't work in this case, because "Object 2" is malformed. It has two times the same propertyoccasions. isMatch casts "Object 2" to a standard Object and this will only keep the last value of this property :occasions-prom. It will then returnfalse.isMatchin my answer. Thanks :)isMatchis not to blame here, any other method would work the same - except when it would take object 2 as JSON and used a tolerant parser internally.