freeCodeCamp/guide/chinese/certifications/javascript-algorithms-and-d.../basic-data-structures/use-the-delete-keyword-to-r.../index.md

629 B

title localeTitle
Use the delete Keyword to Remove Object Properties 使用删除关键字删除对象属性

使用删除关键字删除对象属性

Developer.mozilla.org提供了有关delete运算符的综合教程。

解:

let foods = { 
  apples: 25, 
  oranges: 32, 
  plums: 28, 
  bananas: 13, 
  grapes: 35, 
  strawberries: 27 
 }; 
 // change code below this line 
 delete foods.oranges; 
 delete foods.plums; 
 delete foods.strawberries; 
 // change code above this line 
 console.log(foods);