Global Evaluation

1 minutes
Share the link to this page
Copied
  Completed
Execute some JavaScript code globally.

Transcript

Hello in this jQuery video I am going to show you global evaluation and this allows you to essentially execute put JavaScript code let's say within a function of a limited scope but make make it so it's global inside so let me just show you so if I have a function called epic fun and in here first of all, let's have fun. So what I want to do is do vol equals 27 as my my age and if we do console dot log, epic ball What do you think is gonna happen? Indeed, era epic war is not defined because it has a limited scope. So if you want to create something in here, some code for example, but you want to have make make it so he has global scope. What you do is Dollar dot global eval. So this is global evaluation.

And now what you do is you put quotation marks and in the quotation mark, you put your code itself. So this entire line, the movie, no can reload it, as you can see printed at 27. Even though this is technically created within this function, because we set it to have, you know global scope using the global eval method. We can use it anywhere in the code. So, that's it. I say you global evil.

If you have any questions, feel free to pop me a message and as usual, I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.