-2

I have this object and i want to only get the values that is not an empty string.

const obj = { a: "", b: "b" }

How can i filter out b from this object?

shahirriaz
  • 3
  • 1
  • 5
  • 3
    What did you try? Where did you got stuck? – 0stone0 Mar 28 '22 at 14:50
  • Do you want only the values, as an array? `Object.values(obj).filter(v=>v!=='')`. Or do you want an object that has only properties the value of which are not `""`? – connexo Mar 28 '22 at 14:54

1 Answers1

0

const obj = { a: "", b: "b" }

console.log(Object.values(obj).filter(v=>v!==''))
Arezou Saremian
  • 508
  • 3
  • 8