如果我创建一个类SONG()
并定义了许多属性,我如何创建一个使用传递的参数并获取该属性的方法?
function SONG(i) {
/* properties */
this.title = results.title[i];
this.artist = results.artist[i];
this.album = results.album[i];
this.info = results.info[i];
/* methods */
this.getstuff = function(stuff){
console.log(this.stuff); // doesn't work
}
}
var song1 = new SONG(1);
song1.getstuff(title);
// how can I have this dynamically 'get' the property passed through as an argument?
非常感谢任何帮助或建议!