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

Inheritance implementation code of Javascript class_javascript skills

WBOY
Release: 2016-05-16 18:48:45
Original
966 people have browsed it

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:

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template