Skip to content Skip to sidebar Skip to footer

Undefined Array

public onChange(event: Event) { let files = event.target['files']; let list: string[]; console.log(files); for (var i = 0; i < files.length; i++) { if (F

Solution 1:

you have to initialize the list first:

let list: string[] = [];

when you do just

let list: string[]

you only tell the compiler that this variable will be an array of strings. But at runtime it is undefined, because you didn't initialized it anyway.

Post a Comment for "Undefined Array"