import { head } from "https://deno.land/x/prelude_js@1.2.0/head.ts";
Returns the first element of the given template literal.
Examples
Example 1
Example 1
import { head } from "https://deno.land/x/prelude_js@$VERSION/head.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals(head(""), "");
assertEquals(head("abc"), "a");
Returns the first element of the given string.
Examples
Example 1
Example 1
import { head } from "https://deno.land/x/prelude_js@$VERSION/head.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals(head("" as string), "");
Returns the first element of the given tuple.
Examples
Example 1
Example 1
import { head } from "https://deno.land/x/prelude_js@$VERSION/head.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals(head([]), undefined);
assertEquals(head([1, 2, 3]), 1);
Parameters
input: readonly [T, ...unknown[]]
Any tuple.
Returns the first element of the given iterable.
Examples
Example 1
Example 1
import { head } from "https://deno.land/x/prelude_js@$VERSION/head.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
assertEquals(head(new Set(["x", "y", "z"])), "x");
Parameters
input: Iterable<T>
Any iterable.