javascript - why VScode sometimes don't find the reference? -


it doesn't happen time, visual studio code cannot find variable in other file, , don't know why.

for example, have index.html

<script src="monitor.js"></script> <script src="notificationmanager.js"></script> 

notificationmanager.js

var notificationmanager = function() {     this.attentionrequest = function() {        console.log("attention");     }; } var notificationmanager = new notificationmanager(); 

in monitor.js:

notificationmanager.attentionrequest();//vscode don't find 

it happens

you trying access variable/function declared in js file not available @ time of access. hence, need change order of js files

update from

<script src="monitor.js"></script> <script src="notificationmanager.js"></script> 

to

<script src="notificationmanager.js"></script> <script src="monitor.js"></script> 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -