typescript get object value 1

typescript get object value

const data = {
  a: "first",
  b: "second",

const values = Object.keys(data).map(key => data[key]);

const commaJoinedValues = values.join(",");

Here is what the above code is Doing:
1. We create an object with two keys, a and b.
2. We use Object.keys to get an array of the keys in the object.
3. We use Array.map to create a new array of the values in the object.
4. We use Array.join to create a comma-separated string of the values.

Similar Posts