javascript - Self-executing function in object initialiser can't see object's properties -


i know function scope, self-executing functions, hoisting , other cool words, totally of-base following.

var o = {     : 1,     f : (function(){       console.log(this.a);     })() }; 

why gives me undefined? function self-executed right when object initialized, therefore expect assign 1. not doing this.

because you're not calling via o, this not o.

additionally never assing function either - f set return value (undefined).


Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -