tree: c5b73acbc3f9bc3c206c64279b18b47a26deab35 [path history] [tgz]
  1. .github/
  2. test/
  3. .eslintrc
  4. accessor.d.ts
  5. accessor.js
  6. CHANGELOG.md
  7. index.d.ts
  8. index.js
  9. LICENSE
  10. mutator.d.ts
  11. mutator.js
  12. package.json
  13. README.md
  14. tsconfig.json
node_modules/has-proto/README.md

has-proto Version Badge

github actions coverage License Downloads

npm badge

Does this environment have the ability to set the [[Prototype]] of an object on creation with __proto__?

Example

var hasProto = require('has-proto');
var assert = require('assert');

assert.equal(typeof hasProto(), 'boolean');

var hasProtoAccessor = require('has-proto/accessor')();
if (hasProtoAccessor) {
	assert.equal([].__proto__, Array.prototype);
} else {
	assert(!('__proto__' in Object.prototype));
}

var hasProtoMutator = require('has-proto/mutator');
var obj = {};
assert('toString' in obj);

obj.__proto__ = null;
if (hasProtoMutator) {
	assert(!('toString' in obj));
} else {
	assert('toString' in obj);
	assert.equal(obj.__proto__, null);
}

Tests

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