programing

js 개체에서 전체 속성을 제거하는 방법이 있습니까?

cafebook 2023. 2. 27. 22:21
반응형

js 개체에서 전체 속성을 제거하는 방법이 있습니까?

이상한 질문이긴 하지만 물어봐야 할 것 같아요.

다음과 같은 js 객체가 있는 경우:

$scope.obj1 = {
    "name":"John",
    "number":"Eleven",
    "color":"Red"
}

전체 자산을 제거할 수 있는 방법이 있습니까?을 새 객체에 다시 할당하지 않습니다.그래서 만약 내가 그걸 없애고 싶다면"number":"Eleven",이렇게 생겼으면 좋겠는데...

$scope.obj1 = {
    "name":"John",
    "color":"Red"
}

감사합니다!

JavaScript에는 다음 연산자가 있습니다.

delete $scope.obj1.number

언급URL : https://stackoverflow.com/questions/23619682/is-there-a-way-to-remove-a-whole-property-from-a-js-object

반응형