 which I thought was really cool. You know, many of the warts of JavaScript are just, you know, become moot once you move to CoffeeScript, which seems to be a really, really neat thing. Anyway, so I guess most of you saw the SuperDuper Eval console, but for those of you who haven't, I'll just quickly show you what that is. So, this is basically a little page that I put together to, you know, try simple scripts. So, you know, for example, I can go type, you know, some script there and hit control, enter, I'm a keyboard, because I hate using the mouse as it can. So, you know, the script, put the keyboard, focus back in the script so it can continue debugging. There are some convenience functions. I can use print to print stuff on the console, on the right there. The stuff that we talk about today. All right. So, that's what I wanted to talk about first, right? It turns out that one thing about it is you can pretty much use the function everywhere it is available. So, what can you do with the way that you say bar makes, right? What can you do with that? So, you can assign that to the way it is, right? You can pass variables for the parameters. You can return variables from functions, right? You can manipulate variables in a way. So, you can do all these things. It opens up some very, very interesting scenarios. So, you know, we can probably just quickly look through some of those. I'll try to zoom this in a little bit. All right. So, we'll have to live with that. Okay. So, you know, for example, a regular function, you do this, right? So, this, I'm sure everybody is familiar with. So, define a function, call it, great. Now, it turns out that, you know, this is, you can do this, you know, use this pretty much anywhere that you can use a variable. So, for instance, I can, you know, declare another variable and assign food to that. That works. Turns out, you can call, you know, that function through this variable. So, basically, if you're familiar with C, C++ or C sharp, you know, C sharp delegates or C pointers or C++ function. Yeah, they couldn't in Java to ensure it's the same thing, right? So, F here refers to a function object, right? Or it refers to a executable piece of code. So, you can call it, call it through that. What else can you do with variables? You can pass variables to other functions as parameters, right? So, for instance, if I have a, if I have something like, you know, function, I don't know, foo is good enough. So, I have this. So, I can, I can just do that, right? Now, I'm assuming here that the parameter that you've passed to foo is a function. So, what can I do? I can say, I can say function bar and I'll say footprint bar and here I can say foo of bar, right? And you can see that on the right, you know, it prints bar. So, what happened here? You know, just like a variable. So, I've taken the bar reference, passed it as a parameter to foo and now you're able to call that function indirectly from within foo. What more can you do with functions? Probably something that kind of might be weird is you can return functions from functions, right? So, I can do something like this. So, I can say, I don't know, nested function, right? And now I can say var foo equals this and you'll get rid of that and now I can call this like this. So, you know, it says nested function there. So, what happens if I say var foo equals foo, right? So, that becomes another nested function, right? So, it's actually what's happening here is a new piece of executable code is dynamically getting generated every time I hit foo. We can do interesting things with this particular aspect of it. You know, in functional programming there is this concept of Kareem. Anybody heard of Kareem? Lot of you have heard of Kareem. So, you know, you can do that as well here. So, for example, if you have a function like that a, b, you know, I can return a variant of that where I'm doing it wrong. So, let's say print, I say, S print f, a equals, let's make it a string, b equals that, I can say a, b equals and let's create a utility function, right? Let's say curry or maybe I'll say curry 1 or something, right? So, this is a return function of a, right? And this will simply call fn with a comma param 2, right? So, now I can simply say var. So, I can do this. So, param 1, param 2, obviously. So, clear that. So, that works. And simply directly calling foo, no black magic there. Now, it turns out I can also do this. I can say var f equals curry 1 of foo and now I can say f of p1 and you can see that it still prints, you know, a value for b. I mean, ultimately foo is getting called. But what happened here is, you know, this curry function basically turned a function which took two parameters into a function which takes one parameter, passing a constant for the second parameter, right? I can. But the more I go, the right-hand side kind of disappears. Or maybe I can increase the font, right? That will need some CSS twiddling. I will have to launch this as admin because it is hosted in local IIS here. Sorry about that. Let me just try to quickly do this. Chase foo, 2011. See, I kind of forgot where I put this. Yeah, that's what I was doing. So, if I zoom even any further, this thing goes off. Sorry? Text size, huh? Only this increased. Go back to medium there. You know what, that's actually a good idea. I can do it here. I have script here. I don't think it's going to work out. I did this long back. I don't even remember which one I have to change now. Sorry? So, that's a span. See, I'm using Mozilla's editor for this. That's how you're getting contact-sensitive thing. It generates the whole thing dynamically. Okay, sorry. Too difficult. I mean, if you don't mind, you can come down, sit here. Yeah, I mean, this is not even my code. So, this editor, you know, Mozilla has a project called ACE, which is a complete web development environment on the web. So, I just took the editor piece and put it here. Anyway, so, yeah, so, you know, being able to return functions from functions allows you to implement, you know, carrying from the function programming world. So, you know, those are some interesting things that you can do with functions. Now, there are some more things. Now, okay, so let me get rid of all this. So, we have foo there, right? Now, usually you call this like this. So, you say P1, P2, right? And it prints that. Now, there is an alternative syntax. You can say foo.call of null, P1, P2, right? And that works as well. So, you know, you might wonder, why do we have this? So, why do we have an alternative syntax? Now, this syntax works as fine, right? You just say foo and pass parameter in runs. Looks like there's more work here because there's another parameter here to supply. So, there is a scenario where this really is useful. So, when you define a function, right? What happens if I do something like this? So, what I'll do is I'll say this equals %s and I'll say type of this here, right? And if I say foo of a or b, what do you think is going to print? So, it prints object, right? Now, what is this here? I mean, it's just a global function, right? What could this be here? Window object, right? So, by default, the window context for this particular function, since I haven't explicitly specified a context, the default context is the window, right? Because this is a browser. Node.js, you will have a different context, right? Using a web worker, you have a different context. Basically, different JavaScript runtime environments will have their own context that you can... That's how you're able to, you know, make calls to like, you know, set time out without qualifying with anything. So, if I say setInterval, right? I don't say some object.setInterval, right? You can. You can say window.setInterval. But if you don't do that, the runtime automatically resolves those identifiers to the global context. So, what the first parameter of call allows you to do is specify this context. So, for instance, if I did something like this, right? So, let's say I say name equals this.name there. Now, you know, how can I call this function? Because I have to pass a context. So, what I can do is I can, you know, for instance, I can... Since there's only one, I'll put it on the same line. So, I can do something like this. I can say name colon js2, right? Now, when I run it, you can see that it prints, you know, name. So, basically, that this object here is whatever I pass here, right? So, this allows you to do some, you know, dynamically change the context of a call for a particular function. So, if you notice, this is how actually many of the libraries work. So, for example, in jQuery, when you bind a handler to a particular element's event. So, let's say some div I want to handle the click event on that div. In your handler, you're able to say dollar of this or this. And it actually refers to the html element, right? Now, how is that? Because you are defining a global function. In fact, here I have, you have jQuery also. So, you know, for example, I can say dollar of document dot body dot bind of mouse down, right? Mouse down of function of E. Now, I can say, what shall we say? I say alert this dot outer html, right? Now, I'll run this. And if I go click here, it should have alerted. There you go. So, it allows a scary piece of text. But what's really happening here, right? Because I am defining a global function. I think I have to refresh the page. It's going to be annoying. Copy that. All right. So, wow, this is from the previous session. So, what happened there, right? So, I said document dot body dot bind of click and pass the function. And still I was able to say this, right? So, what's jQuery actually doing is it's taking a callback and doing a dot call on it and passing the element on which you bound the event as the context for that function. So, that's how it works, right? If you've ever wondered, you know, magically this is referring to whatever I hooked it up to. How is that? So, you know, they simply call call on it. Turns out there's yet another way that you can call functions. So, we saw... So, let me just quickly bring that back. So, I'll say print S print F, A equals percentage S, B equals percentage S. So, folks are not familiar with this S print F syntax. It's nothing... It's very, very straightforward. Percentage S refers to... It's basically a placeholder. It means it's a string. It's basically a type specifier. You can say percentage D, percentage F for numbers, floating point values. And I think there are a few other sequences like that. And then basically it's just in the order, right? So, this first percentages will be replaced with the contents of A. Second will be replaced with B and so on. This prevents me from doing that crazy, you know, A equals double code plus variable plus double code. You know, it's very, very annoying. So, now I have this, right? So, we saw the two ways that we can call. Pass the two parameters. You can say foo.call, pass the context, parameter A, parameter B. Now, there is another one that you can do. You can say foo.apply. See, if I just do this, it'll get called, obviously, but you can see that A and B are undefined because I didn't pass the parameters. It turns out how this works is you can do something like this. I can say P1, P2, and it works as before, right? So, the idea with apply is here you pass parameters through an array, right? In case of .call, you have to actually specify each parameter. Here you're able to pass the parameters through an array. And this is really, really useful in many scenarios because foo.call is essentially code that you have to write, right? As in you cannot dynamically do a call on a function with a dynamic set of parameters with call, unless you do eval, which you know is eval. So, don't do eval. So, what do you do, right? So, you have some data which is available to you in an array and you want to pass that to a function which might take that many elements or maybe it's a variable argument function. What are the cases? How do you pass that without using eval, eval? So, you can say function.apply of the context and that array. So, the apply will basically unpack that array and pass the arguments in the correct order. You know, when you need it, this is a very, very useful function to have, though you probably wouldn't need it very often. So, those are some of the things. And just like call, the first parameter is the context. So, this, except a list, yeah. You can do that. You can do that. So, basically what you're suggesting is the function itself can't be modified. So, foo. So, it depends, right? So, if it's a library, you don't have control over it. It's your own function, of course. You can, in fact, that's a very common pattern these days, right? Instead of explicitly listing down the parameters that your API accepts, you basically just give an OPT or something like that, right? And then you expect all the parameters to be either packed into a single JSON object or you can do all kinds of fancy things, right? You can see whether OPT is an object. It's not. It's a number. Then the user is calling it by, you know, passing additional parameters. It's really crazy. You know, these are the times when you wish JavaScript supported overloading, function overloading. It doesn't. So, you have to implement overloading every time. Libraries like jQuery kind of help you with stuff like this, right? So, jQuery has a method called extend, which you can use to just do the appropriate things. For example, you can create a default set of options in your function and then call $.extend on the parameter option. And then what that function will do is whatever is not passed in the function, it will take from your default. So, those things make your life a little easier. So, that's what I want to talk about with regard to functions. We'll talk about functions a little bit more when we talk about closures. I know there's been a lot of talk about closures today. So, we'll briefly cover that as well. So, you know, doing object-oriented development in JavaScript is another interesting topic. We'll keep track on the time here. So, you know, folks coming from a statically typed language background, right, from C-sharp, C++, Java, you know, you miss static typing. So, how many of you prefer dynamic typing? So, it's about 40% of the total. I'll assume that the rest of you prefer static typing. It can be a religious war if you go down that path, actually. You know, people coming from a static language background, when they see JavaScript, they want static features here, right? Everything, you know, if you have a hammer, everything looks like an ale. So, it turns out that you can, to some extent, right? You can simulate object-oriented, static typed classes, inheritance, and so on and so forth. Inheritance is a first-class concept in JavaScript, but it's not the same inheritance that we have in static typed language. Where you have type inheritance, here you have prototype inheritance, right? So, you know, maybe we can try to explore that a little bit. So, you know, JavaScript is designed to work with prototype inheritance, right? It's not meant to work with implementation inheritance or type inheritance as we have in C++ or Java, C-sharp. In fact, Douglas Crockford, who works for YAMU, wrote the book, JavaScript, the good parts. So, he wrote an article in his blog, I think, probably five, six years back, where he, you know, described how you can implement, you know, static type, you know, inheritance with JavaScript. So, he said, you can create an inspector function, you can set the prototype, the base prototype, you can do inheritance, you'll get all that. So, he defined the, described the whole thing. And then a couple of years later, we, you know, wrote another post and he said, I was completely wrong in that post, you know, don't listen to that. So, basically, what he was saying is JavaScript is not designed to do stuff like that, right? The fundamental design of JavaScript is a prototype inheritance-based language. Now, if you do, you know, static kind of things with JavaScript, I think ultimately just confuses matters even further. You know, it's basically, you're fighting with the language, right, to do something. Instead, you know, you should probably do what the language was meant to do. So, how does inheritance work in JavaScript, right? Now, with ECMAScript 5, which I'll probably talk about in the next session, has a, you know, directly supported prototype inheritance. How do you do that? So, for example, if you have an object like this, right? Now, I'll say it has a name, I don't know, name, who? Let's say it has age, and that's it, right? Now, if I want to create an object in JavaScript, everything is based on prototypes. So, it's basically the design pattern, the prototype design pattern is there, right? It's a creation design pattern where how you create, instantiate new instances is by cloning a prototype instance. So, you know, that's the design pattern, right? So, it's a very simple description of it. So, the same thing applies here except you don't clone things. So, it's slightly more clever than that. So, what you can do is you can say O2 equals object.create and pass the prototype as the parameter to that, right? So, now if you do this, I can say O2.name, right? And it prints foo, right? Or I can say O2.age, and it prints 10. So, what is exactly happening here when I say O2.name or O2.age? So, maybe other speakers have covered it already today but I'll very briefly tell you what's going on here. So, the JavaScript runtime, when it encounters access, a member access on some object, when you see some object dot some member, what does it do? So, the first thing it does is it tries to look up whether that property called age exists on that object directly. So, it'll go and look at O2 here, right? And check if O2 is... So, basically everything is an associative array, right? In JavaScript, everything is a hash table. So, I can do it this way or I can actually do it this way. Both will work, right? So, why does that work? Because this is actually an associative array, right? It's a key value, very simple. You can assign values also the same way, right? So, I can say O2 of age equals 20 and then that works as well. So, what's actually happening here? So, a lookup is happening. So, when you say O2 of age, it tries to see whether O2 itself has a property called age. If it does not, then it goes and checks the prototype of O2, which is in this case O1, and see whether the property exists on that object. Yes, then it returns that or assigns to that. So, that is something you need to remember. So, what do you think is going to print if I say print O1.age, right? So, why did that work? Because age was not defined on O2. So, O2 of age should have resolved to the prototype's age, right? Exactly. So, what happens is when you do this, it actually creates age on the new instance, on O2.age, right? So, in fact, if you go here and say, to just to prove that that's what it's doing, I can say now Xmascript 5 has one more new method like create. Probably I'm merging the next session with this session called get prototype of O2. And if I say age, I think I have too much there. So, O1 is 10 and you can see that if I get the prototype object of O2 and get age, that still continues to be 10. It's just that O2 has now a new property called age whose value is 20. To prove this to you even further, what I can do is, I can do something like this. So, ES5 has one more interesting method called object.keys. So, I can say print object.keys of O2 and you can see that it prints an empty array, which means, okay, so I'll tell you what object.keys does. Object.keys is a function. You pass an object to object.keys. It goes and inspects that object and tells you what are the own properties on that particular object. It gives you an array with a string array with the names of the own properties on that particular object. So, right now it says, you know, it has nothing. So, if I put one after the O2 of age, what should we see? So, now you can see that age has magically appeared now, right? That's why the assignment now happens on the O2 objects associative array and it doesn't look into the prototype, which is good, right? Otherwise, it would lead to all kinds of weird problems. Let me do something else. Let me say address, okay? And I'm going to say door number is 5, city is Bangalore, right? Now, let me get rid of, okay, so I'll have O2. So, if I say print O2.address.city, so it'll print Bangalore, nice and fine. But, you know, it turns out that in this particular instance, this is a new instance, right? O2 is a new object, right? So, I can, I should be able to say O2.address.city equals Mumbai, right? And I print that, sure enough, it's Mumbai. But what do you think it's going to print if I say O1.address.city? It prints Mumbai as well, right? Now, this is very different from what we did earlier, because earlier we said 10, 20 and, you know, the original value had a value. But now you can see that the prototypes address field has actually been changed, right? So, what's going on here? Anybody want to take a guess? Exactly, right? So, basically, you have to think of this as maybe something like this, right? Let's say var a equals O2.address, a.city equals Mumbai, right? Just break this line into two lines, then it might be more clearer. So, in this case, which address is it going to give? Prototype. On the prototype. And that's it, right? Now, you're just changing the prototype directly. But this might not be apparent when you are actually, you know, directly doing this. Address.city, you know, like, especially if you're coming from a C++ C sharp background, you know, this would be like a shock for us, right? Wow. The language is broken. It actually kind of is. So, what is the solution for that? You'll have to do deep cloning, right? So, when you say object.so, you'll have to clone the entire object, right? So, you'll probably have to write your own cloning algorithm. Cloning logic. Maybe you can do an object.clone. You pass an object, you know, walk through the properties there and anything that's not a primitive type like a string or a number or a, I don't know what date. I would try that. But anything that's not, you know, anything that's an object, you'll have to do a deep cloning of that and copy it as well. So, so those are some gotchas with, you know, with prototype inheritance that you'll probably have to remember. Now, this is not how most JavaScript code gets written, right? Most JavaScript code gets written like this. Oh, you'll say person, name, age. So, this is what we are used to, right? Name equals name. This dot age equals age. And bar P equals new person. And I can say 2, 10. For a C sharp program, this already looks much, much prettier, right? This feels more natural. There's a class. I'm creating an instance of a class. I'm happy. You know, this was, this syntax was created precisely for that, right? Why do you think it's called JavaScript? You know, there was this talk by Douglas Crockford and a few other, you know, senior JavaScript people in Mix last year. Mix is an event that happens every year in the last week, I think. So, somebody was saying that, you know, JavaScript is not really a scripting language in the sense that, you know, when we say scripting language, we refer to a language that's somehow limited or that is somehow special purpose, right? We create a domain-specific scripting language for one particular objective. So, he's saying it's not because it's actually a full-fledged, you know, programming language, a general-purpose programming language. It's why we're able to use it for server-side with Node.js or Windows 8 for desktop development. So, Douglas Crockford said, then we have named the language completely wrong. It's not Java and it's not a scripting language. And we are calling it JavaScript, right? So, it actually makes complete sense. The only reason it has Java is because Java was very popular at the time and, you know, wanted to attract the Java programmers. And this syntax was introduced for that reason as well. So, you know, but it's useful to understand what is actually happening here when you say var p equals new person of something. So, I'll write some pseudo code. It is not possible to actually write this code, you know, because the JavaScript runtime does not expose that functionality. But I'll write a little piece of pseudo code and I'll tell you which won't work. But when you say var p equals new person of food and so on, this is more or less what is happening. So, first an object gets created like this, okay? So, basically, this syntax here means that this is an empty object. So, what is the prototype of this particular object? It's the object object, right? So, that's where the prototype change ends. So, when you do something like p.do, right? So, I say print of p.do or how can we do this? I was expecting undefined or something to come. Yeah, so I think my print doesn't print undefined. So, you know, it says p.do is undefined, right? Now, where does undefined come from? So, what actually happened was that prototype change lookup happened. So, it looked for do on p, didn't find it. It looked for on p's prototype, didn't find it. It looked in object, didn't find it. Finally, it resolves it to undefined. So, there's no difference. The only reason I use this syntax here is to kind of tell you what's going on because here, p's prototype is now hooked up to object's prototype, which essentially happens even if you do this. There's actually no difference. The only reason why you might do this, we'll probably cover this in the next session, is if you want to define some new ES5 properties, we'll cover that for the root of your hierarchy. Anyway, so essentially what is happening here is something like this. So, it says var p is a new object. Let's use the alternate syntax because that probably makes more sense here. Then it says person.call of p. So, now you know what call does, right? So, this person function here is called as a constructor function because this is supposed to basically construct your object. So, what happens here is person function gets called and the context that's passed is this empty object that got created. So, what happens here? This dot name, this dot age gets created, which means p now gets name and age, right? So, in fact, if I just run this, you will, you know, this will work exactly the same way. So, I'll just comment that line out. I say p dot name. Obviously, I'll have to pass the name 2 and 10. So, print p dot age, right? So, it works exactly as it does if you did this. But then it also does another thing. It sets the prototype of p two persons prototype. Now, this is the code that I said, you know, you can't write. So, it does something that is logically equivalent to this, right? So, this is how you are able to, you know, when you use the function and the var p equals new, you're able to use the instance of operator. In JavaScript has a operator called instance of. So, if I say var o equals new person of a comma 10, if I say print o instance of person, it says truth, right? Now, how does that work? Instance of is very simple. It's a language feature, it's a language operator. But all it does is it sees whether the right-hand side instance of figures in the prototype. So, it will basically walk the prototype chain of the left-hand side argument of o and see if any of those prototypes are equal to what you passed on the right-hand side. So, you know, this kind of proves to you that o's prototype is actually person, right? And the prototype chain person actually figures. So, this is what is actually happening when you do a var o equals new person, right? So, how is that useful to know? Like, when you use that syntax, basically, you know, it's something that the language goes the extra mile to support folks coming from a static background. This is not something that's native to the language. The language is designed to do prototype inheritance, right? So, and the prototype inheritance can go how many of our level deep? Probably in the ES5 session, we'll talk about that. That's interesting. All right. So, this is what I want to talk about. Oh, I think I missed. So, we'll just cover as much as we can, okay? So, we have another 10 minutes. If you have questions, feel free to shoot questions. We can, you know, kind of have an unplugged session. I want to talk about things that have been bothering you. So, let's see. I want to talk about closures. I want to talk about variable hoisting. Maybe I'll talk about variable hoisting because that's very important. Okay. So, let's talk about variable hoisting. I think in the coffee sculpt session, he kind of covered variable hoisting if you attended that session. So, let's try something, right? So, I'll define a function called foo here, right? I'll say alert bar, where bar equals 10. I think it's exactly the same example that he used. What do you think bar is going to be? Oh, I'd call it. So, bar is undefined, right? What will happen if I say BAZ? Actually, it must have given an error. So, it says bars is undefined. So, what is the difference between these two, right? So, for one case, it says it gives you, it throws an exception. A reference error and says BAZ is undefined. Whereas in the other case, it doesn't give you an error. The expression evaluates to undefined, right? So, why is that happening? Exactly. So, in JavaScript, you know, this particular function definition is misleading, right? I think in that sense, I prefer C. C forces you to declare everything on the top, right? You can't declare stuff in the middle. It allows you to do that, but the semantics works correctly, right? Whatever you declare in the middle, this lifetime begins there. JavaScript does something sneaky. What it does is, it changes your function definition to look something like this. Bar, bar, bar equals 10. Now, you can kind of explain this behavior, right? Which makes sense because I've declared the variable bar here. I have not assigned anything to it, therefore it has the value undefined. Allowed undefined makes sense. But the thing is, it does that sneakily behind your back without you knowing about it. So, when you do this, that's what it's doing. And this can have some interesting side effects in your application, right? I mean, all kinds of weird things can happen, right? If you assume that, you know, like where you declare variables is where the scope begins. I mean, the lifetime of the object begins. In fact, the case, everything gets hoisted to the top. It's almost as if it's gone there. So, therefore, the best practice is, do that explicitly, right? Whatever variables you declare, declare at the top. No matter where in the function you're using it, declare it in the beginning of the function. Yeah. Yes, it will. In fact, that was the example that I forget his name. Yes. Yeah, he showed. Otherwise, I'll call him coffee script guy. He showed. So, if I say, wow, if I say war bar equals 20. So, what's going to happen now and defined, right? So, same thing happened because it got hoisted to the top. The global scope, it's called shadowing, right? The global, whatever symbols are available in the global scope got shadowed by your local declarations. So, something that, you know, worth watching out for. So, the best practice is to move it here so that the intent is very clear, right? Now there is no doubt what's going on, right? So, that's a useful thing. Another thing to remember in JavaScript is, again, there's something that you might get tripped up if you are coming from a static type, you know, there's something that I definitely found shocking when I learned about it and I had to try to believe it. So, imagine that I do something like this bar, right? If I say, I'll put a useless check here, it really doesn't matter, right? Here I'll say war bar equals 10. What is bar going to alert now? So, how many of you say undefined? So, how many of you say 20? How many of you say 10? Okay. There were a bunch of people who never raised their hands. So, what are you saying? So, those are the only options, you know, 20, 10 undefined. Okay. So, say it's undefined, right? So, why this is shocking is because in C sharp, C plus plus, Java, this defines a scope, right? A curly brace defines a scope, not so in JavaScript. In JavaScript, the only thing that defines scope is a function, right? That's the only thing that can define a scope, nothing else defines a scope. So, this code is exactly the same as a sneakily JavaScript will go behind your back and do this, right? The exact same thing happens. This also gets hoisted right to the top of your top-way function. So, anytime... So, the best practice around scope is anytime you want to limit the scope of your variables, wrap it inside a function, right? If there is no need for a function to be there, if it is global code and you want to use some variable there, use an immediate function, right? So, an immediate function is basically a function which gets called immediately, right? So, I can say function foo. So, I'll write my... So, I can do that. So, I can go and, you know, declare my variables here. I mean, ABC doesn't really matter, right? So, print immediate, right? So, that got executed. So, basically here, I'm defining the function and calling it at the same time. But the benefit is, this doesn't get leaked into my global scope. ABC is only available within that function. It doesn't get leaked to the global scope, yeah. Oh, five minutes. So, I really wouldn't worry about performance, because, you know, that's like, you know, that's a micro optimization, right? So, it really depends on what JavaScript engine you're running. So, for example, a method JIT JavaScript runtime, JavaScript engine like Firefox's or Chrome's, you know, you might see better performance, because as opposed to writing this in global code, because it will take that whole thing as a function and it will become a piece of native code. I might see a different behavior, opera, safari, I don't know what they do. But, you know, that's like, you probably, at a high level, you don't need to worry about that. Like, if you're really having a performance issue, you know, that time you can probably tweak with stuff like this. But chances are this will not be an issue. All right. Any function will form a variable scope, an execution context. So, you know, that can trip you up, the variable hoisting business. So, I really wanted to talk about that. Happy that we covered that. I don't think you have time to look at anything else. So, some of this stuff, I'll just share some resources. This is an absolutely awesome book. If you read only one JavaScript book this year, read this book. Yeah. Oh, questions. Go ahead.