Curriculum Collections Arrays vs slices exercise 6 · fill-word
Arrays vs slices
Translate xs.slice(0, 3) and xs.slice(3) to idiomatic Go.
Both endpoints in Go's slice expression are optional — omit them
to default to 0 and len(xs).
TypeScript reference
Fill the blanks →
About this theme
Go has fixed-size arrays ([N]T) and dynamically-sized slices ([]T). You almost always want slices. A slice is a view over a backing array — three machine words: pointer, length, capacity. append grows it; make pre-sizes it. The mental model is closer to Rust's Vec than to TS's Array.