Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Use Prototype To Add A Property To Javascript Class

		  class Student{
			  	constructor(name, age)
{				  this.name = name;
				  this.age = age;		 
}			
		  }
	
 
function add()
		  {
			  Student.prototype.eyeColor = "Blue";		  	
	let std=		  new Student("john", 33);
	console.log(std.eyeColor);  
		  }
/*will display blue*/
Comment

Use Prototype To Add A Property To Javascript Class

		  function Student{
		 
 			  this.name = name;
				  this.age = age;		
		 
 		
		  }
	
 
function add()
		  {
			  Student.prototype.eyeColor = "Blue";		  	
	let std=		  new Student("John", 33);
	console.log(std.eyeColor);  
		  }
/*will display blue*/
Comment

PREVIOUS NEXT
Code Example
Javascript :: Assign A New Method To Every Node 
Javascript :: js replay animation 
Javascript :: Self Invoking Functions Can Also be Used To Make Variables Global In JavaScript 
Javascript :: javascript array includes 
Javascript :: how to print in html 
Javascript :: graphql nested schema 
Javascript :: javascript map foreach 
Javascript :: last five characters of string javascript 
Javascript :: class declaration in javascript 
Javascript :: javascript event.target 
Javascript :: add google map in react js 
Javascript :: kafkajs 
Javascript :: what is closures in javascript 
Javascript :: javascript load content from file 
Javascript :: dayjs subtract days 
Javascript :: adding int and string in react props 
Javascript :: getDownload url in firebase 
Javascript :: var function js 
Javascript :: adding pre tag javascript 
Javascript :: datatable change default sorting 
Javascript :: simulate mouse click javascript 
Javascript :: electron hot reload 
Javascript :: Liquid shopify 
Javascript :: reduce function in javascript 
Javascript :: how to clear radio field in jquery 
Javascript :: how to hack facebook 
Javascript :: destructuring nested objects 
Javascript :: filter 2d array javascript 
Javascript :: checks for valid email address syntax javascript 
Javascript :: favicon express js 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =