Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

prototype in javascript

//every object has internal property call prototype.
//prototype is simple reference to another object that
//contain common attributes and methods which will save memeory 
function Todo(name,completed){
this.name=name;
this.completed= completed;
}
Todo.prototype.getTodoName= function(){
console.log(this.name)
}

const todo= new Todo("Buy Eggs", false);
const todo2= new Todo("Learn javascript", false);
todo.getTodoName();
console.log(todo,todo2);
//at console getTodoName will be inside prototype which will save memeory
Comment

javascript prototype example

const array1 = [5, 12, 8, 130, 44];

const found = array1.find(element => element > 10);

console.log(found);

// expected output: 12
Comment

what is Prototype javascript

* Prototype

-Every object in JavaScript has a built-in property,
which is called its prototype. 

-The prototype is itself an object, so the prototype will 
have its own prototype, making what iss called a prototype chain.

-The chain ends when we reach a prototype that has null for 
its own prototype.

-Prototypes are the mechanism by which JavaScript objects inherit
features from one another

const  arr = [1,2,3,4]

// proto type : arr.__proto__
// prototype chain : arr.__proto__.__proto__.__proto__

Comment

what is prototype in javascript

// prototypes in javascript, THey create new Methods to our constructor function
const EmployersInfo =  function(name , salary , bonusPercentage){
    this.name = name ;
    this.salary = salary;
    this.bonusPercentage = bonusPercentage;
}

// prototype for getting the employer credential
EmployersInfo.prototype.credentialInfo = function(){
        return `${this.name} Has a base salary of ${this.salary}`;
}

EmployersInfo.prototype.getBonus = function(){
    let bonusAmount = (this.salary * (this.bonusPercentage));
    return `${this.name} earned ${bonusAmount} Bonus`;
}
// let's first create the instance of employerInform
const employerInform = new EmployersInfo('kevin' , 12000 , 12);

// logging employerInform
console.log(employerInform);

// logging the credentials 
console.log(employerInform.credentialInfo());

// logging the Bonus function 
console.log(employerInform.getBonus());
2
Show 6 More Grepper Results
Comment

what is prototype in javascript

//every object has internal property call prototype.
//prototype is simple reference to another object that
//contain common attributes and methods which will save memeory 
function Todo(name,completed){
this.name=name;
this.completed= completed;
}
Todo.prototype.getTodoName= function(){
console.log(this.name)
}

const todo= new Todo("Buy Eggs", false);
const todo2= new Todo("Learn javascript", false);
todo.getTodoName();
console.log(todo,todo2);
//at console getTodoName will be inside prototype which will save memeory
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for method in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = ()=>{

            return "Arunkumar Chandra";

         };

         document.write("</br>");

         document.write(tutorails.Author());

      </script>   

   </body>

</html>
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for method in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = ()=>{

            return "Arunkumar Chandra";

         };

         document.write("</br>");

         document.write(tutorails.Author());

      </script>   

   </body>

</html>
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for method in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = ()=>{

            return "Arunkumar Chandra";

         };

         document.write("</br>");

         document.write(tutorails.Author());

      </script>   

   </body>

</html>
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for method in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = ()=>{

            return "Arunkumar Chandra";

         };

         document.write("</br>");

         document.write(tutorails.Author());

      </script>   

   </body>

</html>
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for method in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = ()=>{

            return "Arunkumar Chandra";

         };

         document.write("</br>");

         document.write(tutorails.Author());

      </script>   

   </body>

</html>
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for method in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = ()=>{

            return "Arunkumar Chandra";

         };

         document.write("</br>");

         document.write(tutorails.Author());

      </script>   

   </body>

</html>
Comment

use of prototype in javascript

className.prototype.functionname = ()=>{

};
Comment

use of prototype in javascript

className.prototype.functionname = ()=>{

};
Comment

use of prototype in javascript

className.prototype.functionname = ()=>{

};
Comment

use of prototype in javascript

className.prototype.functionname = ()=>{

};
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for variables in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = "Arunkumar Chandra";

         document.write("</br>");

         document.write(tutorails.Author);

      </script>   

   </body>

</html>
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for variables in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = "Arunkumar Chandra";

         document.write("</br>");

         document.write(tutorails.Author);

      </script>   

   </body>

</html>
Comment

use of prototype in javascript

ClassName.prototype.variableName = value;
Comment

what is prototype-based in javascreipt

what is prototype-based in javascript
Comment

use of prototype in javascript

<html>

   <body>  

      Demonstrating prototype for method in javascript

   </br>

   </br>

      <script type = "text/javascript">

         function details(){

           this.website="Tools QA",

           this.language="Java Script"

         }

         var tutorails = new details();

         document.write(tutorails.website);

         document.write("</br>");

         document.write(tutorails.language);

         details.prototype.Author = ()=>{

            return "Arunkumar Chandra";

         };

         document.write("</br>");

         document.write(tutorails.Author());

      </script>   

   </body>

</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: knex js how to group by many items 
Javascript :: js calculate hours between two times 
Javascript :: unexpected text node: . a text node cannot be a child of a <view. 
Javascript :: add item or nothing array js 
Javascript :: $() in javascript 
Javascript :: Argument #1 ($client) must be of type AwsS3Client, AwsS3S3Client given 
Javascript :: telerik jquery grid set page size 
Javascript :: javascript pad 
Javascript :: convert html table to pdf 
Javascript :: get aggregate sum value in kendo grid footer jquery 
Javascript :: NodeJS Multi-Core Processors Example 
Javascript :: verifier si chaien ade caractere apparait dans autre js 
Javascript :: sort an array in descending order javascript 
Javascript :: change placeholder color in material ui 
Javascript :: express.js routing 
Javascript :: d3 js date scatter plot 
Javascript :: how to get specific property name with numbers from object in javascript 
Javascript :: express check request type 
Javascript :: add decimal places to number javascript 
Javascript :: javascript dom functions 
Javascript :: .loads with whole json file 
Javascript :: jsdoc run for all files in folder 
Javascript :: FILTER METHOD. IMPORTANT 
Javascript :: how will you get all the matching tags in a html file javascript 
Javascript :: trying to minimalize the js code and want to increase the performance speed in js 
Javascript :: Issue in applying margin using angular "data-ng-style" 
Javascript :: Navigating to another Screen when a button is tapped in React Native 
Javascript :: Add and remove required attribute based on whether it is visible or hidden 
Javascript :: sending api with limited fields in express 
Javascript :: react native communications 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =