1. object-keys
An Object.keys replacement, in case Object.keys is not available. From https://github.com/es-shims/es5-shim
object-keys
Package: object-keys
Created by: ljharb
Last modified: Fri, 09 Jun 2023 21:33:04 GMT
Version: 1.1.1
License: MIT
Downloads: 141,665,951
Repository: https://github.com/ljharb/object-keys

Install

npm install object-keys
yarn add object-keys

#object-keys Version Badge

Build Status
dependency status
dev dependency status
License
Downloads

npm badge

browser support

An Object.keys shim. Invoke its "shim" method to shim Object.keys if it is unavailable.

Most common usage:

 var keys = Object.keys || require('object-keys');

Example

 var keys = require('object-keys');
var assert = require('assert');
var obj = {
	a: true,
	b: true,
	c: true
};

assert.deepEqual(keys(obj), ['a', 'b', 'c']);
 var keys = require('object-keys');
var assert = require('assert');
/* when Object.keys is not present */
delete Object.keys;
var shimmedKeys = keys.shim();
assert.equal(shimmedKeys, keys);
assert.deepEqual(Object.keys(obj), keys(obj));
 var keys = require('object-keys');
var assert = require('assert');
/* when Object.keys is present */
var shimmedKeys = keys.shim();
assert.equal(shimmedKeys, Object.keys);
assert.deepEqual(Object.keys(obj), keys(obj));

Source

Implementation taken directly from es5-shim, with modifications, including from lodash.

Tests

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code