0
I have an object with 20 keys in total, each key is associated to a value but, value that does not matter for the moment for the answer. So is the object:
var obj = {
1: ...,
2: ...,
3: ...,
...,
20: ...
}
I also have a array with numbers in a row, like this:
var myArray = [ 10, 11, 12, 13, 14, 15, 16, 17 ]
I want to return the same object (obj) but with the Keys same as mine array, example:
var obj = {
10: ...,
11: ...,
12: ...,
13: ...,
14: ...,
15: ...,
16: ...,
17: ...
}
Frederico, in [en.so] you should publish only in portuguese. Use the [Edit] button to translate.
– Woss
You’re right Anderson, it’s fixed!
– Frederico Gomes
Missing the title xD
– Woss
Now it’s time for once xD You can help me??
– Frederico Gomes
Not yet. Your object doesn’t seem to be a valid object in JS. You quote that it has 20 keys, but it looks more like a array. An object relates a key to a value and its objects in the question have no values.
– Woss
Yes in fact each key is associated to a value, but at the moment I only want to work with the keys and hide those that are not in the array. I rewrote it so it’s easier to read.
– Frederico Gomes