Use this:
myFunction.bookName = 'mybook';
myFunction.bookdesc = 'new';
Or, if you are using jQuery:
$(myFunction).extend({
bookName:'mybook',
bookdesc: 'new'
});
The push
method is wrong because it belongs to the Array.prototype
object.
To create a named object, try this:
var myObj = function(){
this.property = 'foo';
this.bar = function(){
}
}
myObj.prototype.objProp = true;
var newObj = new myObj();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…