SoFunction
Updated on 2025-04-10

JavaScript object-oriented programming (I) instance code


<script type="text/javascript">
var test = {
numA: 10,
objB: {},
arrC: [],
init: function(){
alert();
},
sayHi: function(name){
alert("hello " + name);
},
sayHelloWorld: function(){
("world");
},
get: function(){
var self = this;
= function(){
alert();
}
}
};
var TestFunc = function(){
alert("i'm testFunc");
};
= {
extFunc: function(){
alert("this extend function's numB is " + );
},
numB: 10
};
();
("qingming");
();
();
();
var testFunc = new TestFunc();
();
</script>