"함수 unset()"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 7개는 보이지 않습니다)
12번째 줄: 12번째 줄:
[[분류: JavaScript]]
[[분류: JavaScript]]
{{참고|JavaScript delete}}
{{참고|JavaScript delete}}
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
var fruits = {a:'apple',b:'banana',c:'cranberry'};
var fruits = {a:'apple',b:'banana',c:'cranberry'};
delete fruits.b;
delete fruits.b;
console.log( fruits );
console.log( fruits );
// {a: "apple", c: "cranberry"}
// {a: "apple", c: "cranberry"}
</source>
</syntaxhighlight>
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
var fruits = {a:'apple',b:'banana',c:'cranberry'};
var fruits = {a:'apple',b:'banana',c:'cranberry'};
delete fruits['b'];
delete fruits['b'];
console.log( fruits );
console.log( fruits );
// {a: "apple", c: "cranberry"}
// {a: "apple", c: "cranberry"}
</source>
</syntaxhighlight>
<source lang='javascript'>
<syntaxhighlight lang='JavaScript'>
var nums = [101,102,103];
var fruits = ['apple','banana','cranberry'];
delete nums[1];
delete fruits[1];
console.log(nums);
console.log(fruits);
// [101, empty, 103]
// ["apple", empty, "cranberry"]
</source>
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
var fruits = ['apple','banana','cranberry'];
fruits.splice(1,1);
console.log(fruits);
// ["apple", "cranberry"]
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='PHP'>
{{참고|PHP unset()}}
<syntaxhighlight lang='PHP'>
$fruits = [ 'a'=>'apple', 'b'=>'banana', 'c'=>'cranberry' ];
$fruits = [ 'a'=>'apple', 'b'=>'banana', 'c'=>'cranberry' ];
unset($fruits['b']);
unset($fruits['b']);
42번째 줄: 49번째 줄:
//    [c] => cranberry
//    [c] => cranberry
// )
// )
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='Python'>
{{참고|파이썬 del}}
<syntaxhighlight lang='Python'>
fruits = { 'a' : 'apple', 'b' : 'banana', 'c': 'cranberry' }
fruits = { 'a' : 'apple', 'b' : 'banana', 'c': 'cranberry' }
del fruits['b']
del fruits['b']
print fruits
print fruits
# {'a': 'apple', 'c': 'cranberry'}
# {'a': 'apple', 'c': 'cranberry'}
</source>
</syntaxhighlight>


==Perl==
==Perl==
[[category: Perl]]
[[category: Perl]]
<source lang='Perl'>
<syntaxhighlight lang='Perl'>
my %fruits = ( 'a' => 'apple', 'b' => 'banana', 'c' => 'cranberry' );
my %fruits = ( 'a' => 'apple', 'b' => 'banana', 'c' => 'cranberry' );
delete $fruits{'b'};
delete $fruits{'b'};
65번째 줄: 73번째 줄:
#c : cranberry
#c : cranberry
#a : apple
#a : apple
</source>
</syntaxhighlight>
 
==R==
[[분류: R]]
{{참고|R rm()}}
<syntaxhighlight lang='r'>
tmp <- 1:4
tmp
#[1] 1 2 3 4
rm(tmp)
tmp
#Error: object 'tmp' not found
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[함수 removeAt()]]
*[[함수 removeAt()]]
*[[함수 remove()]]
*[[new dictionary]]
*[[new dictionary]]
*[[remove]]
*[[remove]]
*[[array_pop]]
*[[array_pop]]
*[[destructor]]
*[[destructor]]

2021년 3월 19일 (금) 11:18 기준 최신판

  다른 뜻에 대해서는 HTML del 태그 문서를 참조하십시오.
  다른 뜻에 대해서는 리눅스 unset 문서를 참조하십시오.
  다른 뜻에 대해서는 PHP unset() 문서를 참조하십시오.
del
unset
delete

1 JavaScript[ | ]

var fruits = {a:'apple',b:'banana',c:'cranberry'};
delete fruits.b;
console.log( fruits );
// {a: "apple", c: "cranberry"}
var fruits = {a:'apple',b:'banana',c:'cranberry'};
delete fruits['b'];
console.log( fruits );
// {a: "apple", c: "cranberry"}
var fruits = ['apple','banana','cranberry'];
delete fruits[1];
console.log(fruits);
// ["apple", empty, "cranberry"]
var fruits = ['apple','banana','cranberry'];
fruits.splice(1,1);
console.log(fruits);
// ["apple", "cranberry"]

2 PHP[ | ]

$fruits = [ 'a'=>'apple', 'b'=>'banana', 'c'=>'cranberry' ];
unset($fruits['b']);
print_r($fruits);
// Array
// (
//     [a] => apple
//     [c] => cranberry
// )

3 Python[ | ]

fruits = { 'a' : 'apple', 'b' : 'banana', 'c': 'cranberry' }
del fruits['b']
print fruits
# {'a': 'apple', 'c': 'cranberry'}

4 Perl[ | ]

my %fruits = ( 'a' => 'apple', 'b' => 'banana', 'c' => 'cranberry' );
delete $fruits{'b'};

foreach my $key (keys %fruits) {
	my $value = $fruits{$key};
	print "$key : $value\n";
}
#c : cranberry
#a : apple

5 R[ | ]

tmp <- 1:4
tmp
#[1] 1 2 3 4
rm(tmp)
tmp
#Error: object 'tmp' not found

6 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}