Home  >  Article  >  Web Front-end  >  Inheritance implementation code of Javascript class_javascript skills

Inheritance implementation code of Javascript class_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:48:45930browse

To learn classes in JavaScript, methods
inherited from basic classes can also be implemented like this:
Java code

Copy code The code is as follows:

function newClass(){
this.firstName="frank";
this.toUc=String.toUpperCase;
this.toString=function() {
return this.toUc(this.firstName);
}
}
var nc=new newClass();
alert(nc);//No response in IE. .
function newClass(){
this.firstName="frank";
this.toUc=String.toUpperCase;
this.toString=function(){
return this.toUc(this .firstName);
}
}
var nc=new newClass();
alert(nc);//No response in IE. .

A simple client-side validation
Java code

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]

Usually write like this
Java codeCopy code
The code is as follows:



First name:


Last name:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn