spread operator


Node.js

  1. const array = [1, 2, 3, 4, 5]
  2. console.log(...array)

Output

  1. 1 2 3 4 5

Go

  1. package main
  2. import "fmt"
  3. func main() {
  4. array := []byte{1, 2, 3, 4, 5}
  5. var i []interface{}
  6. for _, value := range array {
  7. i = append(i, value)
  8. }
  9. fmt.Println(i...)
  10. }

Output

  1. 1 2 3 4 5