1

Hello I'm trying to delete only the keys from an array, I have this

{everyone: "everyone", random: "random", fast response time: "fast response time", less conversations: "less conversations"}

But I need this array in this way

["everyone", "random", "fast response time", "less conversations"]

I need only the values on this array, I have this code but it brings me an empty array

let array = {everyone: "everyone", random: "random", fast response time: "fast response time", less conversations: "less conversations"};
delete translation['everyone'];
delete translation['random'];
delete translation['fast response time'];
delete translation['less conversations'];
console.log(translation);
1
  • 1
    what's "translation"? Commented Jul 7, 2021 at 19:49

1 Answer 1

6

Object.values() will spit out the values in an array. Also your keys with spaces need to be quoted.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values

const test = {
  everyone: "everyone",
  random: "random",
  "fast response time": "fast response time",
  "less conversations": "less conversations"
}

console.log(Object.values(test));

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, that's what I've been looking foor, thank you so much

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.