B
B
BonBon Slick2021-07-10 21:24:18
typescript
BonBon Slick, 2021-07-10 21:24:18

What does value: [string, any] mean?

I don't see in the doc what the data format is
https://www.typescriptlang.org/docs/handbook/2/nar...
https://www.tutorialsteacher.com/typescript/typesc...

Object.entries(objectOfObjects).forEach((value: [string, any], index: number)  => {
            console.trace({value}); // {value: Array(2)}  --->["teststr", "test"]
            console.trace({index}); // {index: 0}
        });
 Object.entries(objectOfObjects).forEach((value: string | any, index: number)  => {
        Object.entries(violations).forEach((value: (string | any)[], index: number)  => {


If I understand correctly, this is an undocumented array format with string or any as values, that is, any[].

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eggziom, 2021-07-10
@BonBonSlick

This is a tuple (tuple) https://www.typescriptlang.org/docs/handbook/2/obj...
In this case, this is an array in which the 1st element is always string, and the 2nd is any , which Object.entries produces).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question