Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Inside Vs Static Methods

 class Person {
	   constructor(myName) {
	     this.name = myName;
		 console.log(this.getName());
	   }

	   getName() {
	     return this.name;
	   }

	   static getName2() {
	     return 'getName2 result';
	   }
	 }
	 
	 

/*getName can be access either inside the class as this.getName or any instance p of TestClass can access with p.getName()...getName2 However, can only be access via Person.getName2() instances do NOT have access*/
Comment

Inside Vs Static Methods

 class Person {
	   constructor(myName) {
	     this.name = myName;
		 console.log(this.getName());
	   }

	   getName() {
	     return this.name;
	   }

	   static getName2() {
	     return 'getName2 result';
	   }
	 }
	 
	 

/*getName can be access either inside the class as this.getName or any instance p of TestClass can access with p.getName()...getName2 However, can only be access via Person.getName2() instances do NOT have access*/
Comment

PREVIOUS NEXT
Code Example
Javascript :: A Node Module For ReactJS 
Javascript :: Self Invoking Function Tip 
Javascript :: difference between push and pop in javascript 
Javascript :: change button text dynamically angular 6 
Javascript :: javascript how to random set rgb colors 
Javascript :: electron write to csv 
Javascript :: Good Example: Focus moved to AJAX content with tabindex="-1" after a delay 
Javascript :: parseint javascript online 
Javascript :: how to get creator of inetarceton discordjs 
Javascript :: blob to wav javascript 
Javascript :: check if first array contains all elements javascript 
Javascript :: javascript hide div 
Javascript :: trigger oninput of input js 
Javascript :: prevent the Confirm Form Resubmission dialog | window.history.back() confirm form resubmission 
Javascript :: Backbone View Template 
Javascript :: How to Loop Through an Array with a While Loop in JavaScript 
Javascript :: Backbone Model Setting, Has And Getting 
Javascript :: strictPopulate 
Javascript :: react private routes 
Javascript :: react native long form up input 
Javascript :: convert text to number 
Javascript :: electron npm start not working 
Javascript :: ar.js 
Javascript :: mongoose schema for nested items 
Javascript :: fill array with array javascript 
Javascript :: js pow function 
Javascript :: js pick last element of array 
Javascript :: get cos in degree javascript 
Javascript :: javascript Update Values of Properties 
Javascript :: xhr.upload 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =