This course is out of date and does not reflect Frontend Masters current standards. We now recommend you take the JavaScript: The Hard Parts course.
Transcript from the "JavaScript Features" Lesson
[00:00:00]
>> [MUSIC]
[00:00:04]
>> Justin Meyer: Most people now are relatively familiar but know these facts about JavaScript. But just to clear up cuz there's a lot of misconceptions about it, at least a couple of years ago. JavaScript is not Java even though it looks the same. JavaScript is a real programming language, people would say it's like a toy language.
[00:00:22] No, there's big, big, big applications and big software has been written in JavaScript. JavaScript is kind of a synonym for ECMAScript. ECMAScript is a standard and JavaScript is like a trademark name. But if you say ECMAScript, JavaScript i.e this version of JavaScript or Microsoft's version is called JScript.
[00:00:44] These things are all synonyms. If you see one. They all mean about the same thing. Typically if you hear some talk about ECMAScript, it means like a standard. That's coming out for all the different browser vendors to implement. And then JavaScript again is not the DOM, right? Although they're kinda made for each other at this point.
[00:01:05] Okay, so some things about JavaScript the language, that separate it from other languages. And these are the things that I actually I really love about the language. The first is JavaScript is dynamic. So, when you have most other language like compiled language, something like C, what happens is you'll write your C code and you have to compile it, and what a compiler will do is read that code and kind of convert it into byte code.
[00:01:33] And then when you execute that, it's just that byte code is loaded into memory, and then the computer just goes instruction, instruction down in memory. And it's just reading through memory and operating on some other memory somewhere else inside the computer, right? There's a block of memory for code, and there's a block of memory for everything else that the application might use.
[00:01:58]
>> Justin Meyer: JavaScript and dynamic languages like it, are amazing because in some ways you're coding your code, right? With JavaScript or like what jQuery does, jQuery might have a property map like this to create its val in HTML function. And then might iterate through those properties, generating its val in HTML function.
[00:02:21] So here I'm I'm going through every property in propMap, and I'm setting $.prototype to essentially be equal to a function that will call on whatever this is, value or innerHTML. This isn't exactly what jQuery does, but it's similar. You'll see this code a lot in a lot of different libraries, because you're actually building the structures using the language, which you don't really see in compiled languages.
[00:02:51] I really love this nature. So in JavaScript, if you were to look at when the program is running, there is no distinction between the memory that's used for code and the memory that's used for data. That's kinda what dynamic languages give you. JavaScript is also weakly typed, hopefully most people are kind of familiar with this aspect of JavaScript, which is sometimes a bitter pill but also and sometimes very nice.
[00:03:21] Is that you can create a variable and assign it to any type of thing without an error, right? It's because you can think of data in JavaScript as instead of just raw data, instead of just a number in memory, JavaScript data looks like. It's like a little packet it has additional information.
[00:03:43] This data is a number in memory and it has this data, here's the number associated with it. So type travels with a value and not with a variable. And we'll see what this means in a little bit. We wanna break all these things down actually quite a bit.
[00:04:01] And then JavaScript has first class functions. This is another one of my favorite features about the language. Anything you can do with an object in JavaScript, you can do with a function. So I can create a function. I can return a function from within a function. And I can pass functions as arguments.
[00:04:28] And then I can of course, at the very end call a function, which is what most languages give you. This is dynamically creating a language, it's a little bit different than it;s been statically created.
>> Justin Meyer: And then finally, JavaScript is prototype based and we're gonna do a whole like hour on this.
[00:04:49] And really get to understand what this is doing. I'm not gonna go into it in detail right now. So in summary, the DOM is a JavaScript representation of the HTML and a browser, right? It's there for you to kind of manipulate an HTML page, change what's going on inside of a browser.
[00:05:16] It's an interface provided to JavaScript. And then JavaScript itself is a language with all of these kind of interesting quirks that we'll spend today really deep diving into.