I have an object with some concrete fields:
const obj1: Obj = {
hello: true,
second: false,
third: 311,
fifty: 50
.....
}
I need to map some fields from this object to concrete number, (and use it value) and return array with it:
interface ArrayItem {
index: number;
visible: boolean;
}
// hello should be mapped to 3, and visible - 'true'
// result is:
const arr: ArrayItem[] = [{index: 3, visible: true}]
For concrete field. e.g. if obj1, has field "hello", result will be:
[
{
index: 3
visible: (value of 'hello', so -> true)
}
]
More examples:
const obj1: Obj = {
hello: true,
second: false,
third: 311,
fifty: 50
.....
}
// fields, which i looking:
const mapped = {
hello: 3, // index value
second: 5 // index value
}
output:
[
{
index: 3
visible: (value of 'hello', so -> true)
}
{
index: 5
visible: (value of 'second', so -> false)
}
]
Objinto new one only withindexandvisiblekeys, don't you?Objit must containshelloandsecondfields with booleans? And will any other keys affect onArrayItem?