[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object [Back]  [Original]

Object - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Object

Baseline *

20157

*

Object JavaScript Object Object() /

JavaScript Object Object.prototype Object.prototype null null

Object.prototype Object.prototype JavaScript Object.prototype null

Object prototype

Object.prototype Object.prototype null JavaScript

Object.prototype Object.prototype call()

js
const obj = {
  foo: 1,
  // 
  // 
  // 
  propertyIsEnumerable() {
    return false;
  },
};

obj.propertyIsEnumerable("foo"); // false; 
Object.prototype.propertyIsEnumerable.call(obj, "foo"); // true; 

(Map.prototype.delete() ) delete

null

JavaScript Object.prototype null Object.create(null) __proto__: null : __proto__ Object.prototype.__proto__ null Object.setPrototypeOf(obj, null)

js
const obj = Object.create(null);
const obj2 = { __proto__: null };

null Object.prototype /

Object.prototype.toString()

js
const normalObj = {}; // 
const nullProtoObj = Object.create(null); //  "null" 

console.log(`normalObj is: ${normalObj}`); // "normalObj is: [object Object]" 
console.log(`nullProtoObj is: ${nullProtoObj}`); // : Cannot convert object to primitive value 

alert(normalObj); // [object Object] 
alert(nullProtoObj); // : Cannot convert object to primitive value 

js
normalObj.valueOf(); // {} 
nullProtoObj.valueOf(); // : nullProtoObj.valueOf is not a function 

normalObj.hasOwnProperty("p"); // "true" 
nullProtoObj.hasOwnProperty("p"); // : nullProtoObj.hasOwnProperty is not a function 

normalObj.constructor; // "Object() { [native code] }" 
nullProtoObj.constructor; // "undefined" 

toString null

js
nullProtoObj.toString = Object.prototype.toString; //  toString 

console.log(nullProtoObj.toString()); // "[object Object]" 
console.log(`nullProtoObj is: ${nullProtoObj}`); // "nullProtoObj is: [object Object]" 

toString() toString() nullProtoObj nullProtoObj (null)

Object.setPrototypeOf(nullProtoObj, Object.prototype) null

null Object.prototype

js
const ages = { alice: 18, bob: 27 };

function hasPerson(name) {
  return name in ages;
}

function getAge(name) {
  return ages[name];
}

hasPerson("hasOwnProperty"); // true
getAge("toString"); // [Function: toString]

null hasPerson getAge

js
const ages = Object.create(null, {
  alice: { value: 18, enumerable: true },
  bob: { value: 27, enumerable: true },
});

hasPerson("hasOwnProperty"); // false
getAge("toString"); // undefined

Object.prototype Object.prototype null

js
const user = {};

// 
Object.prototype.authenticated = true;

// 
if (user.authenticated) {
  // 
}

JavaScript null API

null Object.prototype extends null

JavaScript 2

toString valueOf

Object()

Object

Object.assign()

1

Object.create()

Object.defineProperties()

Object.defineProperty()

Object.entries()

[key, value]

Object.freeze()

Object.fromEntries()

[key, value] ( Object.entries )

Object.getOwnPropertyDescriptor()

Object.getOwnPropertyDescriptors()

Object.getOwnPropertyNames()

Object.getOwnPropertySymbols()

Object.getPrototypeOf()

( [[Prototype]] )

Object.groupBy()

Object.hasOwn()

true false

Object.is()

2 NaN IsLooselyEqual (==) IsStrictlyEqual (===)

Object.isExtensible()

Object.isFrozen()

Object.isSealed()

Object.keys()

Object.preventExtensions()

Object.seal()

Object.setPrototypeOf()

( [[Prototype]] )

Object.values()

Object.prototype Object

Object.prototype.__proto__

Object.prototype.constructor

Object Object Constructor.prototype constructor

Object.prototype.__defineGetter__()

Object.prototype.__defineSetter__()

Object.prototype.__lookupGetter__()

Object.prototype.__lookupSetter__()

Object.prototype.hasOwnProperty()

Object.prototype.isPrototypeOf()

Object.prototype.propertyIsEnumerable()

Object.prototype.toLocaleString()

toString()

Object.prototype.toString()

Object.prototype.valueOf()

new

js
const o1 = new Object();
const o2 = new Object(undefined);
const o3 = new Object(null);

Object()

Object()

o1 o2

js
// const o1 = new Boolean(true) 
const o1 = new Object(true);

// BigInt() 
// 
const o2 = new Object(1n);

Object.prototype ()

apply() this () Node.prototype Function.prototype

js
const current = Object.prototype.valueOf;

//  "-prop-value" 
//  Object.prototype 
Object.prototype.valueOf = function (...args) {
  if (Object.hasOwn(this, "-prop-value")) {
    return this["-prop-value"];
  }
  // 
  // 
  // apply  "super" 
  // valueOf() 
  return current.apply(this, args);
};

: prototype

ECMAScript 2027 LanguageSpecification
# sec-object-objects


Web Proxy Viewer  |  New URL  |  Original Page