{"id":10798,"library":"es-array-method-boxes-properly","title":"Array Method `this` and Argument Boxing Check","description":"This package, `es-array-method-boxes-properly`, is a niche utility designed to verify the spec compliance of `Array.prototype` methods in a given JavaScript environment. Specifically, it checks if a method like `map` or `forEach` properly \"boxes\" the `this` context (receiver) and the third argument (the array itself) when invoking the callback function. This is critical for ensuring consistent behavior across different JavaScript engines, especially regarding strict mode implications and how primitives are handled when passed as `this`. Currently at version 1.0.0, the package provides a stable API and is likely maintained on an as-needed basis, reflecting its role in foundational spec compliance rather than active feature development. It is primarily used by library authors or engine developers to detect subtle deviations from the ECMAScript specification in host environments.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/ljharb/es-array-method-boxes-properly","tags":["javascript"],"install":[{"cmd":"npm install es-array-method-boxes-properly","lang":"bash","label":"npm"},{"cmd":"yarn add es-array-method-boxes-properly","lang":"bash","label":"yarn"},{"cmd":"pnpm add es-array-method-boxes-properly","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only. For ESM usage, rely on Node.js CJS-ESM interop, dynamic import(), or a bundler.","wrong":"import { boxesProperly } from 'es-array-method-boxes-properly';","symbol":"boxesProperly","correct":"const boxesProperly = require('es-array-method-boxes-properly');"},{"note":"While a CommonJS package, bundlers and Node.js often provide default import interop for convenience.","symbol":"default import (interop)","correct":"import boxesProperly from 'es-array-method-boxes-properly';"}],"quickstart":{"code":"const boxesProperly = require('es-array-method-boxes-properly');\n\n// Check if Array.prototype.map boxes 'this' and the third argument properly\nconst mapBoxesProperly = boxesProperly('map');\nconsole.log(`Array.prototype.map boxes properly: ${mapBoxesProperly}`);\n\n// Example for a method that is known to box differently in some older environments or custom implementations\nconst forEachBoxesProperly = boxesProperly('forEach');\nconsole.log(`Array.prototype.forEach boxes properly: ${forEachBoxesProperly}`);\n\n// You can use this to adapt behavior or report compliance issues\nif (!mapBoxesProperly) {\n  console.warn('Warning: Array.prototype.map implementation might not be spec-compliant regarding boxing.');\n}","lang":"javascript","description":"Demonstrates how to import the `boxesProperly` function and use it to check the compliance of `Array.prototype.map` and `forEach` in the current runtime environment."},"warnings":[{"fix":"Ensure you understand that the check applies to the environment's built-in methods, not custom implementations. If you're using a polyfill, its behavior depends on the polyfill itself.","message":"This utility checks the *host environment's native* `Array.prototype` method implementation for spec compliance. It does not evaluate the behavior of user-defined polyfills or custom array methods, which might have different boxing characteristics.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consult the ECMAScript specification for `Array.prototype` methods to understand the precise requirements for 'boxing' the `this` value and the third argument in callback functions.","message":"The concept of \"properly boxing\" refers specifically to how `this` and the third argument (the array) are treated according to the ECMAScript specification. This often involves primitive values being wrapped in objects when used as `this` in non-strict mode callbacks. Misinterpreting this as a general 'bug' without understanding the spec can lead to incorrect conclusions.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[],"ecosystem":"npm"}