{"id":2089,"date":"2020-04-02T11:21:05","date_gmt":"2020-04-02T15:21:05","guid":{"rendered":"http:\/\/newmediaproduction.mynmi.net\/?page_id=2089"},"modified":"2022-06-10T02:19:48","modified_gmt":"2022-06-10T02:19:48","slug":"intro-to-javascript","status":"publish","type":"page","link":"https:\/\/nmi.cool\/web\/intro-to-javascript\/","title":{"rendered":"Intro to JavaScript"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/nmi.cool\/newmediaproduction\/wp-content\/uploads\/sites\/3\/2020\/04\/katya-austin-I4YsI1zWq_w-unsplash.jpg\" alt=\"Hands touching circular board of lights\" class=\"wp-image-2151\"\/><figcaption>Photo by <a href=\"https:\/\/unsplash.com\/photos\/I4YsI1zWq_w\">Katya Austin<\/a><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Preamble: You&#8217;re awesome!<\/h3>\n\n\n\n<p>Welcome to our final unit of the course\u2014JavaScript! <\/p>\n\n\n\n<p>Before we move forward, take a brief moment to think about how much you&#8217;ve already learned this semester: how to purchase a domain name and hosting, create a web page with HTML and style it with CSS, leverage a front-end framework like Bootstrap, and work with a content management system like WordPress. Way to go! ?<\/p>\n\n\n\n<p>It&#8217;s worth taking the time to celebrate what we&#8217;ve already learned <em>at this particular moment in the course<\/em>, not just because it&#8217;s awesome that you&#8217;ve learned how to do an absolute ton of stuff that you couldn&#8217;t do before, but because this, our final unit, JavaScript, will continue to challenge you, perhaps even more than any of the units we&#8217;ve tackled so far. But take heart! You&#8217;ve already learned so much, and you&#8217;ll learn JavaScript, too. To quote the eternal rallying cry of Gen Z: You&#8217;ve Got This\u2122.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reading: <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/JavaScript\/First_steps\/What_is_JavaScript\">What is JavaScript?<\/a> by Mozilla Developer Network<\/h3>\n\n\n\n<p><code>Required sections: \"<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/JavaScript\/First_steps\/What_is_JavaScript#A_high-level_definition\">A high-level definition<\/a>\" and \"<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Learn\/JavaScript\/First_steps\/What_is_JavaScript#So_what_can_it_really_do\">So what can it really do?<\/a>\"<\/code><\/p>\n\n\n\n<p>The two required sections of this article give a pretty excellent overview of what JavaScript is and the roles it plays in modern web development. <\/p>\n\n\n\n<p>Though JavaScript has actually been extended into all kinds of creative and powerful use cases these days, in our course, we&#8217;re going to focus on its role as &#8220;the third layer of the layer cake of standard web technologies&#8221; alongside HTML and CSS. As the reading continues, &#8220;JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else.&#8221;<\/p>\n\n\n\n<p>We haven&#8217;t dug into JavaScript directly yet, but we&#8217;ve seen it. As the reading notes, &#8220;every time a web page does more than just sit there and display static information for you to look at \u2014 displaying timely content updates, interactive maps, animated 2D\/3D graphics, scrolling video jukeboxes, etc. \u2014 you can bet that JavaScript is probably involved.&#8221;<\/p>\n\n\n\n<p>Some of the more adventurous among you might&#8217;ve incorporated found snippets of JS into Project One, but <em>everyone<\/em> used JavaScript in Project Two (at least three libraries of it, actually! Remember our friends <code>jQuery.js<\/code>, <code>popper.js<\/code>, and <code>bootstrap.js<\/code>?). What role does JS play in Bootstrap? Anything that animated\u2014modals and dropdowns, responsive menus\u2014interacted with JS, as did all of the things listed <a href=\"https:\/\/getbootstrap.com\/docs\/3.4\/javascript\/\">here<\/a>. Most every theme or template included its own additional JavaScript, too.<\/p>\n\n\n\n<p>And, even though WordPress is mostly written in PHP, it includes plenty of JS. In one of your WordPress installs, navigate to <code>wp-admin\/includes\/js<\/code>, and you&#8217;ll see over 90(!) JavaScript files. And, just like Bootstrap, just about every WP theme under the sun includes its own additional JS. too.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">JavaScript is a different sort of thing from the things we&#8217;ve done so far<\/h3>\n\n\n\n<p>HTML and CSS are great, but they&#8217;re ultimately markup and presentation languages. They can structure our information and style it, but ultimately they can only create posters\u2014the aforementioned &#8220;display[s of] static information&#8221;. Granted, they&#8217;re magical, Harry-Potter-style posters that can change size and pull off a few other tricks, but they&#8217;re posters nonetheless.<\/p>\n\n\n\n<p>(Bootstrap is fantastic, but it&#8217;s ultimately a more sophisticated method of building better posters.)<\/p>\n\n\n\n<p>WordPress is a bit different. At the end of the day, we&#8217;re still creating posters (web pages), but these posters are made by a machine\u2014one that assembles web pages out of component parts on demand in powerful, complex ways. <\/p>\n\n\n\n<p>Still, it&#8217;s a machine that someone else built that we&#8217;ve simply been trained to operate. With JavaScript, <strong>we get to build our own machines<\/strong>\u2014machines made out of code that can do almost anything. <\/p>\n\n\n\n<p>Because we&#8217;re just beginning, the machines we&#8217;ll construct in this course are relatively simple. But they&#8217;re real machines, created with one of the most popular programming languages in the world\u2014<a href=\"https:\/\/techbeacon.com\/app-dev-testing\/programming-language-rankings-which-ones-matter\">indisputably in the top 10<\/a>, if not the top 5-6. Vast power awaits you\u2014if you&#8217;ll take the time to learn how to wield it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Approach<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Why bother learning JavaScript?<\/h3>\n\n\n\n<p>Even though you&#8217;re hopefully excited to learn JS after what we&#8217;ve just discussed, some skepticism on your part might well be warranted. After all, without knowing much of anything at JavaScript, you&#8217;ve been able to build some pretty cool stuff on the web!<\/p>\n\n\n\n<p>Without taking a single thing away from what you&#8217;ve built, I&#8217;d argue that every single person who wants to do any sort of front-end web development should know at least a bit of JavaScript. Why?<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">It&#8217;s an essential part of the front end web<\/h4>\n\n\n\n<p>Taking a course in front-end web development without learning JS would be a little bit like learning a second language and never really learning about adjectives or adverbs. You could still communicate, sure, but only in a way that&#8217;s profoundly limited.<\/p>\n\n\n\n<p>More proof of this point: as I mentioned earlier, both Bootstrap and WordPress make extensive use of JavaScript. I&#8217;d be willing to bet that there&#8217;s at least some small part of each of you that&#8217;s a tiny bit curious about how the JavaScript-y parts of the things you&#8217;ve made so far in this course work under the hood.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">It&#8217;s a fantastic introduction to programming<\/h4>\n\n\n\n<p>JavaScript is a true programming language. Also, we fully expect that the overwhelming majority of people who take this course to <em>not<\/em> go into careers in programming. Nevertheless, there are at least two great outcomes to learning a programming language. <\/p>\n\n\n\n<p>The first: what if&#8230;you really like it? Like, what if you really enjoy the kind of thinking and work that programming entails? What if your brain ends up being deeply intrigued by trying to solve the types of puzzles posed by programming? <\/p>\n\n\n\n<p>Programming opens up a huge variety of in-demand, well-paid career paths. (And don&#8217;t worry: if you want to start your journey down this path, there are fantastic NMI electives just for you!)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">It&#8217;s a marketable skill<\/h4>\n\n\n\n<p>Second, for the vast majority of you who don&#8217;t go into full-time programming\u2014or even a primarily technical career path!\u2014the skillset and thought patterns opened up by learning even just the introductory programming skills we&#8217;ll cover in this unit will serve just about everyone well in their future careers. <\/p>\n\n\n\n<p>While we&#8217;re specifically learning JavaScript, more broadly, we&#8217;re learning to <a href=\"https:\/\/www.freecodecamp.org\/news\/how-to-think-like-a-programmer-lessons-in-problem-solving-d1d8bf1de7d2\/\" target=\"_blank\" rel=\"noreferrer noopener\">think programmatically<\/a>. Everyone from film editors to teachers to business leaders to scientists benefit from the ability to think programmatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What should I be able to do?<\/h3>\n\n\n\n<p>In short: read at an intermediate level, speak at a beginner level. <\/p>\n\n\n\n<p>At a very practical level, most of you won&#8217;t need to write arbitrary JavaScript to make cool stuff on the web. What <em>is<\/em> immensely helpful, though, is the ability to, when necessary, drop into a JavaScript file for a project you&#8217;re working on, figure out the lay of the land, and tweak\/extend\/otherwise modify things to make them work exactly the way you want.<\/p>\n\n\n\n<p>Think of it this way: most of us will never frame a whole house from the ground up or cut an entire outfit from whole cloth, but that doesn&#8217;t mean it&#8217;s not still incredibly useful to know how to use a circular saw or a sewing machine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mindset<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Finding comfort and giving grace<\/h4>\n\n\n\n<p>Learning any programming language can at times feel like a super-un-fun two-step between unbearable boredom and impossible complexity. You will likely feel both of the following feelings:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&#8220;Okay, yes, shut up already, I&#8217;m in college, I know how to <em>add two numbers<\/em>, for crying out loud.&#8221;<\/li><li>&#8220;I&#8217;ve tried this 57 times, and I&#8217;m more convinced than ever that this exercise is flat-out impossible.&#8221;<\/li><\/ul>\n\n\n\n<p>In navigating these competing feelings, try to focus on this: while some concepts (basic math! putting words together!) might feel incredibly simple, you&#8217;ll quickly be asked to apply them in entirely new ways of thinking. Find peace and comfort in the parts of learning how to program that feel familiar, and give yourself grace when an exercise or challenge feels impossible. <\/p>\n\n\n\n<p>Remember, you&#8217;re learning a new way of thinking, so <em>of course<\/em> some things will feel familiar (how could you learn this new way of thinking without at least some parallels \/ analogies to things you already know?) and <em>of course<\/em> some things will feel alien and incomprehensible (how could you learn this new way of thinking without encountering something strange and challenging?).<\/p>\n\n\n\n<p>One more thing: JavaScript is unforgiving in ways that HTML and CSS are not. Because HTML and CSS are bounded languages (there&#8217;s a limited vocabulary of options to work with within each), if your HTML or CSS has a small error, the browser will still try its best to guess what you mean and try to render <em>something<\/em>. JavaScript, though, is a true programming language, a browser&#8217;s JavaScript engine can&#8217;t really guess what you mean\u2014you could feasibly be trying to do anything! All of that to say, when you have a small error in JavaScript, expect errors that stop your code from running, even if it&#8217;s just a missing space or punctuation mark. Knowing this in advance won&#8217;t eliminate frustration, but it might help reduce it.<a href=\"#footnote-1-2089\" id=\"note-1-2089\" rel=\"footnote\">1<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"comprehension-mostly-over-completion\">Comprehension (mostly) over completion<\/h4>\n\n\n\n<p>From <a href=\"https:\/\/nmi.cool\/web\/attitudes-and-habits\/\">Attitudes and habits<\/a>:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>&#8230;prioritize comprehension over completion. Don\u2019t just finish your daily lessons\u2014seek to truly understand the concepts they\u2019re communicating. The skills in this class are largely sequential and additive. If you don\u2019t understand something early in the class, the impact of that gap in your understanding will only be magnified as we go on.<\/p><p>I\u2019d much rather move a bit more slowly to achieve deeper understanding. Always feel free to ask me or your peers for clarification or help.<\/p><\/blockquote>\n\n\n\n<p>This admonition is perhaps more true for JavaScript than for any other unit of this course. As you make your way through the FreeCodeCamp exercises, really take the time necessary to understand each new concept as it&#8217;s introduced.<\/p>\n\n\n\n<p>At this point in the course, though, it&#8217;s appropriate to add a wrinkle to the above: sometimes the best way to comprehension is by first achieving completion <em>without<\/em> comprehension. What does this mean?<\/p>\n\n\n\n<p>You absolutely should still try to complete each lesson on your own first, and then by consulting the provided hints and\/or your classmates. However, with JavaScript in particular, if you&#8217;re well and truly stuck, it can be a helpful strategy to check out the solution\u2014or to watch the associated videos (they&#8217;re great!), which often provide the solution\u2014and <em>then<\/em> take the time to study the solution and figure out why and how it works.<\/p>\n\n\n\n<p>One final note in this area: functional comprehension is the goal, not perfect and total understanding. There are many layers to learning a programming language, and lessons will sometimes discuss in passing concepts you don&#8217;t understand or provide a simplistic explanation of something you might correctly suspect is more complex. As you&#8217;re learning JavaScript, aim to understand well enough to achieve the goals set before you at the present moment. You can always go back and revisit a concept later if you find your grasp on it isn&#8217;t quite as firm as you first thought.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Resources<\/h2>\n\n\n\n<p>Thankfully, there are <strong>tons<\/strong> of amazing resources out there to help learn JavaScript. Here are a few of our favorites.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/grasshopper.app\">Grasshopper<\/a><\/h3>\n\n\n\n<p>A part of the Code with Google program, Grasshopper is a free coding app for beginners in which you&#8217;ll:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&#8220;Learn with fun, quick lessons on your phone that teach you to write real JavaScript.&#8221;<\/li><li>&#8220;Move through progressively challenging levels as you develop your abilities.&#8221;<\/li><li>&#8220;Graduate with fundamental programming skills for your next step as a coder.&#8221;<\/li><\/ul>\n\n\n\n<p>The best part about Grasshopper is that it&#8217;s cross-platform and is actually practical to use on a phone, allowing you to work on your skills on the go.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a rel=\"noreferrer noopener\" href=\"http:\/\/jsforcats.com\/\" target=\"_blank\">JavaScript for Cats<\/a> ?<\/h3>\n\n\n\n<p><em>So easy your human companion could do it too!<\/em><\/p>\n\n\n\n<p>Regardless of your feelings towards cats, this introduction to JavaScript is as informative as it is silly. To make the most of introductory tutorial, we suggest following along with the instructions, using the <strong>console<\/strong> tab in your browser. If you haven&#8217;t used the console tab before, don&#8217;t worry: The author\/cat(?) walks you through how to access it. <\/p>\n\n\n\n<p>This resource will take roughly half an hour to go through, but it&#8217;s well worth the time investment if you want to have a solid understanding of basic JavaScript syntax. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/projects.raspberrypi.org\/en\/projects\/cd-beginner-javascript-sushi\" target=\"_blank\" rel=\"noreferrer noopener\">Guess the colour! <\/a><\/h3>\n\n\n\n<p>From the Raspberry Pi Foundation, a UK-based charity designed to make coding accessible to everyone, this color guessing game introduces you to beginner-level JavaScript, as well as how to use programming concepts to solve problems. <\/p>\n\n\n\n<p>Although this game assumes no prior knowledge of JavaScript, we suggest going through it after you&#8217;ve done a few FCC lessons. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.freecodecamp.org\/news\/the-complete-javascript-handbook-f26b2c71719c\/\" target=\"_blank\" rel=\"noreferrer noopener\">The JavaScript Beginners Handbook<\/a><\/h3>\n\n\n\n<p>Free Code Camp published a beginner&#8217;s handbook to JavaScript that is a great complement to the Free Code Camp lessons that you&#8217;ll be working through in this unit. This serves as an excellent reference for when you get deep into one of the FCC coding challenges and can&#8217;t quite remember how to access an element of an array or what the <em>logical and<\/em> operator looks like. You can bookmark this website or download a pdf version of the handbook. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/nmi.cool\/web\/javascript-to-do-list\/\">JavaScript To-Do List<\/a><\/h3>\n\n\n\n<p>A short exercise in which you can tweak the JavaScript in a semi-real-world-type scenario. Fun? \u2705<\/p>\n<div class=\"footnotes\"><hr \/><ol><li id=\"footnote-1-2089\" class=\"footnote\"><p>Maybe.<a href=\"#note-1-2089\" class=\"footnote-return\">&#8617;<\/a><\/p><\/li><!--\/#footnote-1.footnote--><\/ol><\/div><!--\/#footnotes-->","protected":false},"excerpt":{"rendered":"<p>Overview Preamble: You&#8217;re awesome! Welcome to our final unit of the course\u2014JavaScript! Before we move forward, take a brief moment to think about how much you&#8217;ve already learned this semester: how to purchase a domain name and hosting, create a web page with HTML and style it with CSS, leverage a front-end framework like Bootstrap, &hellip; <a href=\"https:\/\/nmi.cool\/web\/intro-to-javascript\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Intro to JavaScript<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2089","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/nmi.cool\/web\/wp-json\/wp\/v2\/pages\/2089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nmi.cool\/web\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/nmi.cool\/web\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/nmi.cool\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nmi.cool\/web\/wp-json\/wp\/v2\/comments?post=2089"}],"version-history":[{"count":3,"href":"https:\/\/nmi.cool\/web\/wp-json\/wp\/v2\/pages\/2089\/revisions"}],"predecessor-version":[{"id":3646,"href":"https:\/\/nmi.cool\/web\/wp-json\/wp\/v2\/pages\/2089\/revisions\/3646"}],"wp:attachment":[{"href":"https:\/\/nmi.cool\/web\/wp-json\/wp\/v2\/media?parent=2089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}