var o = { p: 1, f: function() { return this.p; } }; document.getElementById('out').textContent = o.f();
<div id='out'>test</div>