paramSheet: { name: any, amount: any, date: any } = {
name: '',
amount: '',
date: ''
};
Is there any function to clear/reset the variables.
other than this.
this.paramSheet.name.reset();
this.paramSheet.amount.reset();
this.paramSheet.date.reset();
this.paramSheet.name = ‘’;
this.paramSheet.amount = ‘’;
this.paramSheet.date = ‘’;
thanks.in advance.
This question sure would be a lot easier to answer if there wasn’t so much any
in it.
Okay. What can be done if variable is like this.
paramSheet: { name: string, amount: number, date: Date } = {
name: ‘’,
amount: ‘’,
date: ‘’
};
In that case we have a syntax error because so-called “smart” quotes aren’t valid JavaScript. If we replace them with ''
or ""
then we get type errors because strings are neither valid numbers nor Date
s.
Which sort of explicates the larger problem here, which is that “clear/reset” is not a clearly-defined concept in general. Only you can define what constitutes a “clear” Date
. undefined
? null
? Now? The beginning of the UNIX epoch in 1970? MacOS’s leap-year-special-case-avoiding choice of the start of 1904?
1 Like
Sorry for that forgot to change.