Skip to main content
Module

x/isx/mod.ts>hasOwn

TypeScript-first is function collections
Go to Latest
function hasOwn
import { hasOwn } from "https://deno.land/x/isx@1.0.0-beta.24/mod.ts";

Whether the value has the property or not. The difference from Object.hasOwn is that it has a Type guard.

Examples

Example 1

import { hasOwn } from "https://deno.land/x/isx@$VERSION/mod.ts";

const object: object = {};
if (hasOwn("", object)) {
  object[""]; // No type error.
}

Type Parameters

T extends PropertyKey
U extends { }

Parameters

key: T

Any property key.

value: U

Any object.

Returns

value is U & [k in T]: unknown