Most appends write into free capacity in O(1). Occasionally the array resizes and copies O(n) elements; spread over many appends, the average cost per append stays O(1) (amortized).
let capacity = 4;
let size = 0;
function append(x: number) {
if (size === capacity) {
capacity *= 2; // resize + copy O(n)
}
size++;
}