Languages
[Edit]
EN

TypeScript - remove function from object

0 points
Created by:
Lillie-Rose-Finnegan
489

In TypeScript, you shouldn't remove existing functions from objects as this can lead to errors.

Such things can be solved by deleting the object to a different type (e.g. omitting a property) or creating a new object that does not contain the method that we want to omit.

Practical examples

Edit

Example 1

Example 2

Note:

student2 contains print() method, but the type it was cast to does not.

 Example 3

Example 4

Edit

Alternative titles

  1. TypeScript - how to remove function from object?
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join