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

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

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