Talks
JavaScript For People Who Didn't Learn JavaScript
Summarized using AI

JavaScript For People Who Didn't Learn JavaScript

by Javascript for people who didn't learn Javascript

The video, "JavaScript for People Who Didn't Learn JavaScript" presented by Jesse Wolgamott at the LoneStarRuby Conf 2011, focuses on fundamental concepts of JavaScript that are often overlooked, particularly by those who have primarily used jQuery. Wolgamott begins by engaging the audience with a personal story and emphasizing that the talk aims to clarify important aspects of JavaScript. The following key points are discussed:

  • Distinguishing JavaScript from jQuery: Wolgamott shares his experience of confusing jQuery with JavaScript, highlighting that jQuery is not a programming language.
  • Prototype Inheritance: The speaker explains prototype inheritance, comparing it to Ruby modules. He illustrates how JavaScript searches up the inheritance chain, emphasizing the dynamic nature of prototypes and how they can be modified.
  • Functions as First-Class Citizens: The talk includes a simple 'hello world' example to demonstrate how in JavaScript, everything is a function, which helps in understanding JavaScript's flexibility.
  • Dynamic Prototyping: Changes made to a prototype impact all objects created from it, showcasing this through dynamic method updates.
  • The Controversy of 'new': The speaker navigates the debate around using the 'new' keyword and advises caution in its application, depending on the context of object creation.
  • Variable References: Wolgamott underscores the importance of understanding that variables in JavaScript are passed by reference, which can lead to unexpected behavior during assignments.
  • Equality Issues: He warns against the pitfalls of using '==' due to type coercion, advocating for '===' to ensure strict equality checks.
  • Key Takeaways: Wolgamott stresses embracing JavaScript's prototype nature and suggests leveraging object literals and functions for simplicity. He recommends foundational learning and exploring further into frameworks such as Node.js and Backbone.
  • Resources: The speaker ends by recommending "JavaScript: The Good Parts" as a valuable resource for understanding the language better.

In conclusion, the presentation emphasizes the importance of grasping JavaScript fundamentals for developers looking to efficiently use frameworks and expand their programming skill set.

00:00:20.560 So this is 'JavaScript for People Who Didn't Learn JavaScript'. Just to make sure, who here has used JavaScript in their life? Oh, it looks like I made a mistake with a sock! I think we're done if everybody here has used it. That's it. Thank you, thank you, thank you.
00:00:45.840 My name is Jesse Wolgamott, and I live in Houston. You can find me on Twitter at @jwo. There's also 'CodeMav', which a friend of mine, JB, just wrote. It compiles everything, so if you want more information about me than you ever wanted to know, that's where you go. The slides for this talk are available right here, so if you want to check them out or if you've got any questions, we'll do a Q&A.
00:01:12.799 A personal story to introduce relatability: I am wearing the conference t-shirt right now because yesterday we drove up from Houston, and I did not pack another shirt. I was hoping that we were going to get a t-shirt today; otherwise, I wasn't quite sure what I was going to do. I tried to auction off some sponsorship opportunities, but it didn't quite happen.
00:01:50.079 I do have a confession to make. A little while ago, I thought I knew JavaScript, but really, I knew jQuery. And jQuery is not a language. So how much of this is JavaScript, and how much of it is just jQuery? We can look at it; we're getting all the labels and the body items and attaching a click event to them. This is cool stuff. It does run JavaScript, but in my opinion, this is not JavaScript as it comes to be known.
00:02:32.640 I thought that if I knew how to make jQuery dance, I was pretty good at JavaScript. To a certain extent, that's true, but when you start to get into some of the hotter stuff that's happening right now, some of the cooler stuff with Node and Backbone, if you don't know the fundamentals, it's a little bit scary. At least, it was for me.
00:03:03.280 So today, we're going to talk about prototype inheritance. We're going to discuss how JavaScript does not keep it classy; it does not have classes. We’ll explore whether we should use 'new' or not, scopes, and how we can learn from CoffeeScript.
00:03:30.239 JavaScript right now is the new hotness. Last year, I gave a talk here on document databases, and since this is a Ruby conference, I decided to give a talk on JavaScript instead. Everything that's happening in JavaScript today is pretty cool. We'll talk about prototype inheritance, which can be scary if you don't know what it is.
00:03:48.319 I describe prototype inheritance as being a lot like Ruby modules. In Ruby, when you execute a method, it starts asking, 'Do you define this?' The class, the modules included—if none of those defines it, the search goes up the inheritance tree until reaching `object.prototype`. If it's not found, you get 'undefined'.
00:04:21.039 The difference with Ruby modules is that you can only have one prototype per function, but you can switch it out as needed. So I think of prototype inheritance as modules that you're bringing into your functions and classes, which can change behaviors or add new functionalities.
00:04:40.639 Next, everything is a function. In our example, we start with a simple 'hello world' application, where 'hello world' is a literal that has a `speak`, which has the text 'hello'. We replace it with a function and show how you can declare `helloworld.speak()` and call it. Everything goes on its merry way, showing that everything is essentially a function.
00:05:34.320 Another interesting part about prototypes is their dynamic nature. If you have a prototype, some methods on it, and you create objects from that prototype, any updates to the prototype will flow through to the objects created from it. For example, we log an output formatter and change the properties, reflecting these changes dynamically.
00:08:00.879 In JavaScript, when we need to change the behavior of a class, we'll often override that method. To illustrate, if we're extending a Backbone model, we might override the `set` method. We have to call super explicitly when we need to retain the original functionality while adding new features.
00:09:45.920 Should you use 'new'? It's a controversial topic. Douglas Crockford once said to never use 'new', but I believe it’s not that binary. The idea is not to use it blindly, but sometimes it is necessary if you want the prototype of the object. For example, you may want to create a new model, so you apply the prototype tree, but for a simple array, you don't need 'new'.
00:10:45.920 In JavaScript, variables are passed around by reference, not by value. If you have a variable containing an object and then assign it to another variable, both will point to the same object. This can lead to unexpected results if you modify one and expect it not to affect the other.
00:25:12.320 Equality in JavaScript can be tricky. Using '==' can lead to unexpected behavior because it performs type coercion. Therefore, it’s recommended to use '===' to avoid these pitfalls and ensure strict equality.
00:27:18.880 As for takeaways: prototype inheritance is important—don't hide it. Instead, embrace JavaScript's prototype nature or find alternatives if you dislike it. Use object literals for arrays and functions for simplicity. Finally, CoffeeScript can make JavaScript better, but understanding the fundamentals of JavaScript is still essential.
00:28:59.840 For resources, 'JavaScript: The Good Parts' is a highly recommended book. Also, consider getting deeper into JavaScript frameworks and libraries like Node.js and Backbone, as they'll compel you to learn the fundamentals behind the language.
00:30:07.039 So now, let's address any questions you may have about JavaScript or the topics we covered today.
Explore all talks recorded at LoneStarRuby Conf 2011
+15