Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

hasown

inspect-js157.3mMIT2.0.2TypeScript support: included

A robust, ES3 compatible, "has own property" predicate.

has, hasOwnProperty, hasOwn, has-own, own, has, property, in, javascript, ecmascript

readme

hasown Version Badge

github actions coverage License Downloads

npm badge

A robust, ES3 compatible, "has own property" predicate.

Example

const assert = require('assert');
const hasOwn = require('hasown');

assert.equal(hasOwn({}, 'toString'), false);
assert.equal(hasOwn([], 'length'), true);
assert.equal(hasOwn({ a: 42 }, 'a'), true);

Tests

Simply clone the repo, npm install, and run npm test

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v2.0.2 - 2024-03-10

Commits

  • [types] use shared config 68e9d4d
  • [actions] remove redundant finisher; use reusable workflow 241a68e
  • [Tests] increase coverage 4125c0d
  • [Tests] skip npm ls in old node due to TS 01b9282
  • [types] improve predicate type d340f85
  • [Dev Deps] update tape 70089fc
  • [Tests] use @arethetypeswrong/cli 50b272c

v2.0.1 - 2024-02-10

Commits

  • [types] use a handwritten d.ts file; fix exported type 012b989
  • [Dev Deps] update @types/function-bind, @types/mock-property, @types/tape, aud, mock-property, npmignore, tape, typescript 977a56f
  • [meta] add sideEffects flag 3a60b7b

v2.0.0 - 2023-10-19

Commits

  • revamped implementation, tests, readme 72bf8b3
  • [meta] revamp package.json 079775f
  • Only apps should have lockfiles 6640e23

v1.0.1 - 2023-10-10

Commits