3. JavaScript
Hello
Zen and the art of Coding
Please email hello@zenandtheartofcoding.info for a password
Hello

JavaScript

prologue

  • this is it. JavaScript is coding.
  • JavaScript (or just JS) is my official personal recommendation when anybody tells me that they want to learn to code. I used to go back and forth between Python and JavaScript and have staunchly landed on JavaScript; unless the reason a person wants to learn to code is related to data science or AI. For general web dev, frontend AND backend, learning data structures and algorithms, building SaaS platforms, desktop apps, native mobile apps for iOS & android, hell even video games, it's JavaScript all fucking day.
  • the previous sections are really for context to JavaScript. JavaScript is modern web development and software engineering.
  • JavaScript is an object-oriented programming language.
  • JS has traditionally been used for "dynamic client-side scripting", which means it was the piece of the puzzle that made things work on websites (instead of just statically displaying things). JS is still that but the truth is JS has become so much more than that in recent years.
  • a few reasons JS is so important
    • node.js (opens in a new tab), which let's you write server-side (backend) JavaScript
    • TypeScript which allows for static typing, which has become a standard in frontend and backend engineering
    • the JS frameworks and libraries like Angular, Vue and React
  • also before we get into it, know that JavaScript is not the same thing as Java. its like "car" and "carpet", two totally different languages

intro

  • JavaScript is the language of the modern internet. you don't even need to use a code editor like VS Code to start writing JS, you just need a browser.
  • in any browser you can open up developer tools.
    • if you are on a mac, hit option + command + i, or ctrl + shift + i on windows/linux
  • when you first open developer tools on a browser it will usually first default open to the Elements tab which the the HTML for the web page you are on.
  • some browsers like Safari and Chrome have a JavaScript console right at the bottom of the Elements tab, look for the >. if your browser (like Brave) doesn't have a JS console at the bottom of the Elements tab or if you just want some more room to breathe, switch over to the Console tab.
  • click next to the > at the bottom and you can start writing JavaScript.
  • try it. type in 2 + 2 and hit enter. oh shit, did you know you had a JS calculator in your browser?
  • if math is the reason you thought about learning to code but were scared off, try this instead: type alert("math sux") and hit enter. sick now you are a real hacker.
  • you can actually write full functions in the developer tools, hold shift when you hit enter to write on the next line.
  • we're going to create our own JS files and use a code editor in the next section.