함수 push()

  다른 뜻에 대해서는 영어 push 문서를 참조하십시오.
  다른 뜻에 대해서는 jQuery .add() 문서를 참조하십시오.
  다른 뜻에 대해서는 jQuery .append() 문서를 참조하십시오.
add
push
append
array_push

1 Bash[ | ]

ARR=()
ARR+=("John Smith")
ARR+=("Jane Doe")
ARR+=("Mike Barnes")
for VALUE in "${ARR[@]}"; do echo "[$VALUE]"; done
# [John Smith]
# [Jane Doe]
# [Mike Barnes]
ARR=()
ARR=("${ARR[@]}" "John Smith")
ARR=("${ARR[@]}" "Jane Doe")
ARR=("${ARR[@]}" "Mike Barnes")
for VALUE in "${ARR[@]}"; do echo "[$VALUE]"; done

2 Go[ | ]

package main

import "fmt"

func main() {
	var fruits = []string{"banana", "orange"}
	fruits = append(fruits, "apple", "mango")
	fmt.Println(fruits) // [banana orange apple mango]
}

3 Java[ | ]

List<String> mylist = new ArrayList<String>();
mylist.add("Mike Barnes");
mylist.add("Kevin Patterson");

4 JavaScript[ | ]

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
console.log( fruits );
// ["Banana", "Orange", "Apple", "Mango", "Kiwi"]

5 PHP[ | ]

$arr = [];
$arr[] = "John Smith";
$arr[] = "Jane Doe";
$arr[] = "Mike Barnes";
$arr = [];
array_push($arr, "John Smith");
array_push($arr, "Jane Doe");
array_push($arr, "Mike Barnes");
$fruits = ["Banana", "Orange", "Apple", "Mango"];
$fruits[] = "Kiwi";

6 Python[ | ]

  다른 뜻에 대해서는 파이썬 append() 문서를 참조하십시오.
fruits = ["Banana", "Orange", "Apple", "Mango"]
fruits.append("Kiwi")
print( fruits )
# ['Banana', 'Orange', 'Apple', 'Mango', 'Kiwi']
fruits = ["Banana", "Orange", "Apple", "Mango"]
fruits += ["Kiwi"]
print( fruits )
# ['Banana', 'Orange', 'Apple', 'Mango', 'Kiwi']

7 Perl[ | ]

my @fruits = ("Banana", "Orange", "Apple", "Mango");
push @fruits, "Kiwi";
print "@fruits\n";
# Banana Orange Apple Mango Kiwi

8 Ruby[ | ]

fruits = ["Banana", "Orange", "Apple"]
fruits.push("Kiwi")
print fruits
# ["Banana", "Orange", "Apple", "Kiwi"]
fruits = ["Banana", "Orange", "Apple"]
fruits << "Kiwi"
print fruits
# ["Banana", "Orange", "Apple", "Kiwi"]

9 같이 보기[ | ]

10 참고[ | ]

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