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

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
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 fruits = ['apple','banana','cranberry'];
var fruits = ['apple','banana','cranberry'];
delete fruits[1];
delete fruits[1];
console.log(fruits);
console.log(fruits);
// ["apple", empty, "cranberry"]
// ["apple", empty, "cranberry"]
</source>
</syntaxhighlight>
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
var fruits = ['apple','banana','cranberry'];
var fruits = ['apple','banana','cranberry'];
fruits.splice(1,1);
fruits.splice(1,1);
console.log(fruits);
console.log(fruits);
// ["apple", "cranberry"]
// ["apple", "cranberry"]
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='PHP'>
<syntaxhighlight lang='PHP'>
$fruits = [ 'a'=>'apple', 'b'=>'banana', 'c'=>'cranberry' ];
$fruits = [ 'a'=>'apple', 'b'=>'banana', 'c'=>'cranberry' ];
unset($fruits['b']);
unset($fruits['b']);
48번째 줄: 48번째 줄:
//    [c] => cranberry
//    [c] => cranberry
// )
// )
</source>
</syntaxhighlight>


==Python==
==Python==
[[category: Python]]
[[category: Python]]
{{참고|파이썬 del}}
{{참고|파이썬 del}}
<source lang='Python'>
<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'};
72번째 줄: 72번째 줄:
#c : cranberry
#c : cranberry
#a : apple
#a : apple
</source>
</syntaxhighlight>


==R==
==R==
[[분류: R]]
[[분류: R]]
{{참고|R rm()}}
{{참고|R rm()}}
<source lang='r'>
<syntaxhighlight lang='r'>
tmp <- 1:4
tmp <- 1:4
tmp
tmp
84번째 줄: 84번째 줄:
tmp
tmp
#Error: object 'tmp' not found
#Error: object 'tmp' not found
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:33 판

  다른 뜻에 대해서는 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 }}