airbnb_javascript_helpers

1.0.1 • Public • Published

Set of helpers to make it easier to follow one of the best JavaScript Style Guide.

#####Shortly: Do not call Object.prototype methods directly, such as hasOwnProperty, propertyIsEnumerable, and isPrototypeOf.

Why? These methods may be shadowed by properties on the object in question - consider { hasOwnProperty: false } - or, the object may be a null object (Object.create(null)).

// bad
console.log(object.hasOwnProperty(key));

// good
console.log(Object.prototype.hasOwnProperty.call(object, key));

// best
import { hasOwnProperty } from 'airbnb_javascript_helpers';

console.log(hasOwnProperty(object, key));

And this rule applies to all prototype methods.

Usage

npm i -S airbnb_javascript_helpers

####List of helpers:

Object

  • hasOwnProperty(obj, key)
  • isPrototypeOf(obj, arg)
  • propertyIsEnumerable(obj, prop)

Dependencies (0)

    Dev Dependencies (11)

    Package Sidebar

    Install

    npm i airbnb_javascript_helpers

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • sarkistlt