Reputation: 69
let thesentence = 'I having a good day'
console.log(thesentence.substr(0,4))
the substr
has a strikethrough effect, but using substring
is fine.
Upvotes: 3
Views: 1594
Reputation: 52080
It's crossed out because it's deprecated. That's a JS/TS VS Code feature that deprecated things are displayed with a strikethrough effect.
If you mouseover it and wait for the hover info to appear, you'll see this:
@deprecated — A legacy feature for browser compatibility
The @deprecated
annotation in the doc comment of the typings (defined by lib.es5.d.ts (part of TypeScript)) is what makes VS Code know that it's deprecated. You can find the change that marked it as deprecated in the TypeScript typings in this commit: Update lib types to mark Annex B as deprecated (#43710)
To read about why substr
is deprecated, see Why is String.prototype.substr() deprecated?.
Upvotes: 1