Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What's the best way to remove properties and functions from an object in Javascript?

user-image
Question ajoutée par Yasmeen Husam , Web Developer , Al Fahid Systems
Date de publication: 2019/01/28
youssouf touhami
par youssouf touhami , Chief Service Management Information- IT Department , NAFTAL

Theres is tow Option:

1- Delete is the true way to remove object's properties without any leftovers, but it works slow

2- setting object[key] = undefined.

Example:

Delete: 

Var obj ={ feild:1 }; 

delete obj.feild;

Undefined: 

Var obj ={ feild:1 }; 

obj.feild=undefined;

 

Adel Abou Elezz
par Adel Abou Elezz , Full Stack Developer , Rama Group

this may help you 

var myObject = { "ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*" }; delete myObject.regex;

Loullah AHMEDOU
par Loullah AHMEDOU , Software Engineer , GTI International

using "delete" keyword

Example:

delete myObject.aProperty;

Muhammad Farhan
par Muhammad Farhan , Web Desinger , Fiverr

You can Use Delete Statement to remove this.

eg. Delete obj.property

Muhammad Sajjad
par Muhammad Sajjad , Full Stack Web Developer , Phlox Solutions

Simply use the Delete key word

Example: 

var test ={'red':'#FF','blue':'#FF'};

delete test.blue;

 

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?