# "this" keyword-1

{% embed url="https://youtu.be/3bBDUl1FGw8" %}



```dart
void main() {
  
  
  
  // Significance of "this" keyword 
  
  
  var  employee1 =   Employee();  // Creating employee1 object   
  
  var  employee2 =   Employee(); // Creating employee2  object 
  
  
  
  //Attribute <=> Instance Variable <=> Field Variable 
  
  
   // Setting the instance variable of employee1 object 
   
  employee1.id =1;
  employee1.firstname ="John";
  employee1.lastname ="Doe";
  employee1.position = "CTO";
  employee1.number_of_day_worked=12;
  
  
  
  employee2.id =2;
  employee2.firstname ="Jane";
  employee2.lastname  ="Doe";
  employee2.position ="CEO";
  employee2.number_of_day_worked=10;
  
 // companyname for employee2 will be set to "A" , because we 
 // didn't set it, it take the default value from class 
  
  
  
  
   // Methods Calling <=> Invoke method 
  
  
  //
  
  
   employee1.calculate_salary();
  
   employee1.fullname();
  
   
  
   
  
   print("-----------------------");
  
  
  
  
   employee2.calculate_salary();
  
   employee2.fullname();
  
  
}



class Employee{
  
  
  int id;
  
  String firstname;
  
  String lastname;  
  
  String position;
  
  int number_of_day_worked;
  

  
  
  
  //Method 
 
  void team_meeting_schedule(){
    
    // logic for team_meeting 
    
   
   
    
  }
  
  
  
  void fullname(){
    
    //logic for full name 
    
    print("${this.firstname}"+" "+"${this.lastname}");
    
  }
    
  void calculate_salary(){
    
    // logic for calculating salary
    
    int per_day_income = 100;
    
    print("${per_day_income*(this.number_of_day_worked)}");  
    
  }
  
}
```

{% hint style="success" %}
Think of  "this" as a placeholder or a reference variable for an instance . When we invoke a method on an instance , "this" is replaced by that instance&#x20;
{% endhint %}

{% tabs %}
{% tab title="Employee Class " %}
![](https://1972396024-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCuqiBdVbVkT07RwbQD%2F-MDLkUINu0d13iQA4YSK%2F-MDLknF4F9wt8SCK2PKK%2F1.svg?alt=media\&token=791172e7-a47e-431f-a288-3313519c774a)
{% endtab %}

{% tab title="employee1 instance  " %}
![](https://1972396024-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCuqiBdVbVkT07RwbQD%2F-MDLkUINu0d13iQA4YSK%2F-MDLkvuMrolr3Jeu3NTs%2F2.svg?alt=media\&token=30c97697-79e4-4f77-9db3-8f377512aea9)
{% endtab %}

{% tab title="employee2 instance " %}
![](https://1972396024-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MCuqiBdVbVkT07RwbQD%2F-MDLkzpQdrcCuVbgGQTd%2F-MDLl7VwhfFkg15Zc3oa%2F3.svg?alt=media\&token=c660d7b6-53ba-49f0-b9e8-9c0a4bc8a19b)
{% endtab %}
{% endtabs %}

More about "this" keyword in&#x20;

{% content-ref url="../constructor/parameterised-constructor/basic-parameterised-constructor" %}
[basic-parameterised-constructor](../constructor/parameterised-constructor/basic-parameterised-constructor)
{% endcontent-ref %}

