In var sample = function() { // constructor code here } sample.prototype.func1 = function() { // func1 code here } sample.prototype.func2 = function() { // func2 code here } /* more sample prototype functions here... */ Then use the following code to instantiate and access the prototype method: var sampleInstance = new sample(); sampleInstance.func1(); sampleInstance.func2(); // call more sample object prototype functions But if we want to rewrite one of the prototype methods without destroying the original var subSample = function() { // constructor code here } // inherit from sample subSample.prototype = new sample(); subSample.prototype.fun1 = function() { // overwrite the sample's func1 } However, if you do not build an inherited class and want to rewrite the prototype method, you can directly use the following code: var sampleInstance = new sample(); sampleInstance.func1 = function() { sample.prototype.fun1.call(this); // call sample's func1 // sampleInstance.func1 code here } We redefined the This is the end of this article about the details of overriding prototype methods in You may also be interested in:
|
<<: XHTML Getting Started Tutorial: Form Tags
>>: Solve the error during connect exception in Docker
1. Each function is an object and occupies memory...
1. Introduction MySQL comes with a replication so...
The common way to deploy a springboot project to ...
I recently stumbled upon the Audiovisual Linux Pr...
Ubuntu 20.04 has been officially released in Apri...
1. Add users and groups 1. Add mysql user group #...
In the previous article, we introduced: MySQL8.0....
Table of contents 1. Get a random Boolean value (...
When making a form in a recent project, I need to...
Table of contents pom configuration Setting.xml c...
First: Installation of MySQL Download the MySQL s...
Adding background image control to a component re...
The content involved in Web front-end development...
MySQL Daemon failed to start error solution A few...
1. Introduction MDL lock in MYSQL has always been...