js基础的问题请教?
window.onload = function() {
function Base() {
this.elements = [];
}
Base.prototype.getId = function(id) {
this.elements.push(document.getElementById('a'));
alert(this); //这行的this
};
Base.getId('a');
};
window.onload = function() {
function Base() {
this.elements = [];
}
Base.prototype.getId = function(id) {
this.elements.push(document.getElementById('a'));
alert(this); //这行的this
};
var base = new Base();
base.getId('a');
};
function test() {
console.log(this.x);
}
var o = {};
o.x = 1;
o.m = test;
o.m();
test();