Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JavaScript Object Prototype

// constructor function
function Person () {
    this.name = 'John',
    this.age = 23
}

// creating objects
let person1 = new Person();
let person2 = new Person();

// adding new property to constructor function
Person.prototype.gender = 'Male';

console.log(person1.gender); // Male
console.log(person2.gender); // Male
Comment

javascript object prototype

function listAllProperties(o) {
  let objectToInspect = o;
  let result = [];

  while(objectToInspect !== null) {
    result = result.concat(Object.getOwnPropertyNames(objectToInspect));
    objectToInspect = Object.getPrototypeOf(objectToInspect)
  }

  return result;
}
Comment

access the prototype of an object javascript


var f = function();
var instance = new f();

Comment

access the prototype of an object javascript

Object.getPrototypeOf(x);

//Output
ƒ () { [native code] }
Comment

PREVIOUS NEXT
Code Example
Javascript :: how does square root work javascript 
Javascript :: class declaration in javascript 
Javascript :: password 
Javascript :: brightness javascript 
Javascript :: e.target.value with number 
Javascript :: javascript methods 
Javascript :: javascript this = that 
Javascript :: what is local storage and session storage in javascript 
Javascript :: blur javascript 
Javascript :: switch case 
Javascript :: js functional ajax requests 
Javascript :: event.target 
Javascript :: javascript post 
Javascript :: remove duplicates array javascript 
Javascript :: uncaught typeerror e.indexof is not a function jquery load 
Javascript :: firebase realtime database increment value 
Javascript :: how to log all messages discord.js 
Javascript :: An unhandled exception occurred: Script file ../node_modules/jquery/dist/jquery.min.js does not exist. 
Javascript :: js flatten 
Javascript :: moment isbetween 
Javascript :: javascript wait for async function to finish 
Javascript :: button is not calling js function 
Javascript :: get sessionstorage value in jquery 
Javascript :: how to add a function in javascript 
Javascript :: in express how do you set the location header 
Javascript :: quadratic equation in js by function 
Javascript :: how to get font size in javascript 
Javascript :: Create a Simple Delay Using setTimeout 
Javascript :: find longest word in a string javascript 
Javascript :: showdown react 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =