Languages
[Edit]
EN

JavaScript - how to remove function from object?

2 points
Created by:
Marcin
15710

In JavaScript it is possible to remove function from object in 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);

 

Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join