1.6 KiB
1.6 KiB
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56bbb991ad1ed5201cd392d3 | JavaScript オブジェクトからのプロパティの削除 | 1 | https://scrimba.com/c/cDqKdTv | 17560 | delete-properties-from-a-javascript-object |
--description--
次のようにオブジェクトからプロパティを削除することもできます。
delete ourDog.bark;
例:
const ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"],
"bark": "bow-wow"
};
delete ourDog.bark;
上記の最後の行の後の ourDog
は次のようになります。
{
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
}
--instructions--
tails
プロパティを myDog
から削除してください。 ドット記法またはブラケット記法のいずれも使用できます。
--hints--
プロパティ tails
を myDog
から削除する必要があります。
assert(typeof myDog === 'object' && myDog.tails === undefined);
myDog
の設定を変更しないでください。
assert(code.match(/"tails": 1/g).length > 0);
--seed--
--after-user-code--
(function(z){return z;})(myDog);
--seed-contents--
// Setup
const myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"],
"bark": "woof"
};
// Only change code below this line
--solutions--
const myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"],
"bark": "woof"
};
delete myDog.tails;