Dev Helpers
← Back

Return a translated point

Return a translated point using TypeScript.

Open this example in the interactive library

Source code

type Point = readonly [x: number, y: number];
const point: Point = [3, 4];
console.log(
  (([x, y]: Point, dx: number, dy: number): Point => [x + dx, y + dy])(
    point,
    2,
    -1,
  ),
);

Sample output

[ 5, 3 ]