I'm wondering, is there a difference (actual or best practices wise) between
interface Fruit {
cost?: number;
}
and
interface Fruit {
cost: number | undefined;
}
If there is an actual difference in terms of behaviour, what is it?
If there isn't, why would one prefer | undefined or ?: (or vice versa)?
Sort of confused because I've seen both, and not sure if there's actually an actual reason for preferring one over the other, or if it's something that just boils down to preference.
Thanks!