var fullname = 'Вася';
var obj = {
fullname: 'Петя',
prop: {
fullname: 'Маша',
getFullname: function () {
return this.fullname;
}
}
};
var test = obj.prop.getFullname;
console.log(test()); // undefined
var fullname = 'Вася';
var obj = {
fullname: 'Петя',
prop: {
fullname: 'Маша',
getFullname: function() {
return this.fullname;
}
}
};
var test = obj.prop.getFullname;
console.log(test.bind(obj.prop)());
console.log(test.apply(obj.prop));
console.log(test.call(obj.prop));
(function() {
console.log(obj.prop.getFullname());
})()