Sto cercando di verificare se esiste un indice di array a macchina, dal seguente senso (solo per esempio):Typescript - Come verificare se esiste un indice di array?
var someArray = [];
// Fill the array with data
if ("index" in someArray) {
// Do something
}
Tuttavia, sto ottenendo il seguente errore di compilazione:
The in operator requires the left operand to be of type Any or the String primitive type, and the right operand to be of type Any or an object type
Qualcuno sa perché è così? per quanto ne so, quello che sto cercando di fare è completamente legale da JS.
Grazie.
Si deve usare un oggetto, non un array. – SLaks
"indicizza" una stringa o un indice numerico effettivo? – elclanrs
una stringa. Immagino che farò come ha detto SLaks, ho pensato che anche gli array di dattiloscritti possono essere usati anche come array associativi. – gipouf