Hmm, explanation is okay, but try giving some more info, like:
constbrand_name="mercedes";// Global variablefunctionsuv(){constsuv_name="g-wagen";// Local variablesdocument.querySelector("h1").innerHTML="vehicle :"+suv_name+brand_name;}functionsedan(){document.querySelector("h2").innerHTML="vehicle :"+suv_name+brand_name;// Here it gives an error bcz suv_names // is not defined in this function or or // globally, but it's defined in another function,// so it will be private for this function}
Hence Global variables can be used any where in the code, but local variables can be accessed only in that particular function,
if you explain like this with more info, people can understand
I typed it in mobile, so if you find any typos, please ignore.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hmm, explanation is okay, but try giving some more info, like:
Hence Global variables can be used any where in the code, but local variables can be accessed only in that particular function,
if you explain like this with more info, people can understand
I typed it in mobile, so if you find any typos, please ignore.