Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Accessing Function Declared Outside Constructor But Inside Class

  
class Person
{
constructor(name)
{
    this.name = name;

this.hello();
}

hello()
{
    alert("hello");
}

}
 
/*if the function is declared outside the constructor, access it with this inthe constructor*/
 
PREVIOUS NEXT
Tagged: #Accessing #Function #Declared #Outside #Constructor #But #Inside #Class
ADD COMMENT
Topic
Name
1+4 =