Saturday 29 September 2018

Global functions in javascript

I'm new to js and trying to understand global and private functions. I understand global and local variables. But if I have an html named test.html and a 2 js files named test1.js and test2.js. Now I include the test1.js and test2.js in test.html and call the functions written in test2.js inside test1.js and test.html.



The functions that I have written in test2.js are in this form



function abc(){...}

function pqr(){...} etc.


are these above functions global? If they are , how can I not make them global and still access them in test1.js and test.html?



As I have read global functions or global variables are bad right?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...