JSFiddle - React, Tailwind, and code Playground
by dshilkret
JavaScript
/* const array = ['value1', 'value2', 'value3'];
const object = { key1: 'value1', key3: 'value3', key4: 'value4' };
// Method to find matching values
const matches = Object.values(object).filter(value => array.includes(value));
console.log(matches); // Output: ['value1', 'value3'] */
/* const array = ['value1', 'value2', 'value3'];
const object = { key1: 'value1', key3: 'value3', key4: 'value4' };
// Method to find matching values without arrow function
const matches = Object.values(object).filter(function(value) {
return array.includes(value);
});
console.log(matches); // Output: ['value1', 'value3'] */
const array = ['value1', 'value2', 'value3'];
const object = { key1: 'value1', key3: 'value3', key4: 'value4' };
const matches = Object.values(object).filter(function(value) {
return array.includes(value);
});
console.log(matches); // Output: ['value1', 'value3']