Languages
[Edit]
EN

JavaScript - how to remove function from object?

2 points
Created by:
Marcin
2444

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);

 

Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.