Am learning more deeply about JS and YUI in order to make dynamic elements for a form that is for defining a question type with drag and drop images. But this is essentially a js question with no knowledge of the filepicker required.
I want to hook into the js for the filepicker.
But playing about with the code I am very puzzled that what I see in the console.log does not necessarily correspond to the variable contents available at the time.
For example if I edit repository/filepicker.js :
M.core_filepicker = M.core_filepicker || {};
/**
* instances of file pickers used on page
*/
M.core_filepicker.instances = M.core_filepicker.instances || {};
console.log(M.core_filepicker.instances);
The console does not output an empty object but outputs an object with the 7 initialised filepicker helper instances I am using later on the page!
Strange. It seems anywhere after the object is created console thinks it has properties. Before the initial assignment I get an error saying instances is not defined.
What am I not understanding about JS scope or execution sequence?
Jamie