Tuesday, 9 May 2017

Remove property in Javascript




I have the following object



b.push({ data: d, width: 5, color: color });


then I have




b= [{data:10,width:5, color:"yellow"},{data:12,width:5, color:"red"},etc...];


I added color property and now I do not need and I want to remove it. I would like to know what is easiest way to do it?


Answer



You can delete it using delete



delete b[0].color

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...