I am trying to concatenate two strings in TypeScript like this:
let string1 = new String("IdNumber: " + this.IdNumber);
let string2 = new String(this.notes);
this.notes = string1.concat(string2.toString());
The output I see for this.notes on line 3 is missing the original text from this.notes in string2. This is what I see in devTools for this.notes on line 3 when debugging:
"IdNumber: 524242
"
when hovering over this.notes on line 2 in devTools it looks like this:
"testing
testing 2
testing 3"
I was hoping that this.notes on line 3 would look like this:
"IdNumber: 524242
testing
testing 2
testing 3"
What am I doing wrong?
this
context is missing so it's hard to know what's going on. I concur thatnew String(...)
is almost certainly not what you want to do; you could use justString(...)
instead. But without being able to reproduce the issue, this is all just guesswork."IdNumber: " + this.IdNumber + this.notes
wouldn't give you.