Skip to content

Instantly share code, notes, and snippets.

@gordey4doronin
Created August 25, 2020 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gordey4doronin/148f60c80cfedbfaa3eb3031e433d24c to your computer and use it in GitHub Desktop.
Save gordey4doronin/148f60c80cfedbfaa3eb3031e433d24c to your computer and use it in GitHub Desktop.
Check the prototype of an object in JavaScript
var buffer = Buffer.from('something')
console.log('buffer.__proto__')
console.log(buffer.__proto__)
console.log()
console.log('buffer instanceof Buffer')
console.log(buffer instanceof Buffer)
console.log()
console.log('buffer.constructor')
console.log(buffer.constructor)
console.log()
console.log('buffer.constructor.name')
console.log(buffer.constructor.name)
console.log()
console.log('Object.getPrototypeOf(buffer)')
console.log(Object.getPrototypeOf(buffer))
console.log()
@gordey4doronin
Copy link
Author

buffer.__proto__
Buffer {
  readBigUInt64LE: [Function: readBigUInt64LE],
  // ...
  // ...
  toLocaleString: [Function: toString],
  [Symbol(nodejs.util.inspect.custom)]: [Function: inspect] }
buffer instanceof Buffer
true
buffer.constructor
{ [Function: Buffer]
  poolSize: 8192,
  from: [Function: from],
  of: [Function: of],
  alloc: [Function: alloc],
  allocUnsafe: [Function: allocUnsafe],
  allocUnsafeSlow: [Function: allocUnsafeSlow],
  isBuffer: [Function: isBuffer],
  compare: [Function: compare],
  isEncoding: [Function: isEncoding],
  concat: [Function: concat],
  byteLength: [Function: byteLength],
  [Symbol(kIsEncodingSymbol)]: [Function: isEncoding] }
buffer.constructor.name
Buffer
Object.getPrototypeOf(buffer)
Buffer {
  readBigUInt64LE: [Function: readBigUInt64LE],
  // ...
  // ...
  toLocaleString: [Function: toString],
  [Symbol(nodejs.util.inspect.custom)]: [Function: inspect] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment