//Definition of class
//Method 1: General definition method of class
function player1(_name)
{
= _name;
= function() {alert();};
}
var p1 = new player1('llinzzi1');
();
//Method 2: Prototype definition method
var player2 = function() {}
= {
name:'',
say:function(){
alert();
}
}
var p2 = new player2();
= 'llinzzi2';
();
//Method 3: The above method is beautiful and convenient, but the construction function cannot have parameters, so modify the method
var player3 = function() {
(this, arguments);
}
= {
init:function(_name){
= _name;
},
say:function(){
alert();
}
}
var p3 = new player3('llinzzi3');
();
//Inheritance of Class
//Method 1
var player4 = function(){
(this, arguments);
}
= new player3;
= function(){
alert(());
}
var p4 = new player4('llinzzi4');
();
//Method 2 The above method cannot use the {} method, modify the method
= function(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
};
var player5 = function(){
(this, arguments);
}
((,),{
shout:function(){
alert(());
}
});
var p5 = new player5('llinzzi5');
();
//Then judge the code from the copy browser
Browser = {
IE: !!( && !),
Opera: !!,
WebKit: ('AppleWebKit/') > -1,
Gecko: ('Gecko') > -1 && ('KHTML') == -1,
MobileSafari: !!(/Apple.*Mobile.*Safari/)
}
alert();
//Method 1: General definition method of class
function player1(_name)
{
= _name;
= function() {alert();};
}
var p1 = new player1('llinzzi1');
();
//Method 2: Prototype definition method
var player2 = function() {}
= {
name:'',
say:function(){
alert();
}
}
var p2 = new player2();
= 'llinzzi2';
();
//Method 3: The above method is beautiful and convenient, but the construction function cannot have parameters, so modify the method
var player3 = function() {
(this, arguments);
}
= {
init:function(_name){
= _name;
},
say:function(){
alert();
}
}
var p3 = new player3('llinzzi3');
();
//Inheritance of Class
//Method 1
var player4 = function(){
(this, arguments);
}
= new player3;
= function(){
alert(());
}
var p4 = new player4('llinzzi4');
();
//Method 2 The above method cannot use the {} method, modify the method
= function(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
};
var player5 = function(){
(this, arguments);
}
((,),{
shout:function(){
alert(());
}
});
var p5 = new player5('llinzzi5');
();
//Then judge the code from the copy browser
Browser = {
IE: !!( && !),
Opera: !!,
WebKit: ('AppleWebKit/') > -1,
Gecko: ('Gecko') > -1 && ('KHTML') == -1,
MobileSafari: !!(/Apple.*Mobile.*Safari/)
}
alert();