Languages
[Edit]
EN

JavaScript - remove function from object

2 points
Created by:
Kenya-Spears
800

In JavaScript, it is possible to remove a function from an object in the following way.

1. delete operator example

// ONLINE-RUNNER:browser;

var student = {
	name: 'John',
  	print: function() { /* nothing here... */ }
};

console.log(student.print);

delete student.print; //delete student['print'];

console.log(student.print);

Output:

function() { /* nothing here... */ }
undefined

Alternative titles

  1. JavaScript - how to remove function from object?
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