Code Speed Dating: Meet JavaScript
A brief introduction to a lovely programming language
Back into some technical posts! I’ll be doing this little section occasionally called Code Speed Dating, where we’ll take a 5-minute-read approach to introducing different coding languages. After all, we’re busy ladies (and gentlemen), and don’t have time unless we like what we see…
Recently, I took a step back from PHP — or forward, as the case may be — to pursue Treehouse’s Full-Stack JavaScript track. One of my favorite parts of Treehouse’s classes are their instructors, especially Dave McFarland and Andrew Chalkley (with his charming accent!), and so far, the JS track is delivering as a clear, concise introduction and deeper dive.
Meet JavaScript: Tall, Dark, and Powerful
JavaScript is a pretty intensely powerful front-end (and back-end, as we’ll see) language, designed to make your web pages interactive with the user. In its most basic form, where it shines is in its ability to make things happen on a web page in the user’s browser. Now, it became clear to me over time that there are lots of ways these days to add interactivity to web pages, but this hasn’t always been the case. Back in the late 90s/early 2000s, when I was a young dork trying to figure out how to make a cool blog page for me to share all my TMI on, options were limited at best or non-existent. But JavaScript has come a long way since its birth in 1995 (it’s young, but don’t let that deter you; it has an old soul). I had a chance to meet JS in my adult life, when we were both all grown up… and I am oh-so-happy that I did.
Now, you’ll likely find that if you want to do something minor like making a link do something when you move your mouse over it, you may be able to use either CSS or JavaScript. However, if you want to integrate an interactive program where, say, the site counts down to a specific date… JavaScript’s your jam. This is by no means a comprehensive idea of what it is capable of, but seeing as I haven’t even scratched the surface myself in terms of its capabilities… I’m not going to be your best resource just yet. ;) Stay tuned!
Ok, What’s JavaScript Look Like?
If you’re a superficial kind of person (or are concerned that when you’re walking down a dark alley at night, you’ll need to be able to recognize JavaScript if it jumps out of the shadows), then have a gander:
A simple line of JavaScript code to return “Hello World!” to the web page:
document.write( 'Hello, world!' );
How about a pop-up alert, a.k.a. one of the things JS was best recognized for back in the 1990s (It’s grown up since then. We all made bad choices in the 90s.):
alert( 'Hello, world!' );
Basic if/else logic in JavaScript. This checks if a variable var is greater than 0. If is it, it writes ‘True”. If it isn’t, it writes “False”:
if ( var > 0 ) {
document.write( 'True' );
} else {
document.write ( 'False' );
}
Don’t worry if this looks like a whole lot of nonsense to you now. Much like any other language, code or verbal, familiarity and repeated exposure breeds comfort. :)
The Treehouse JavaScript Track
As of the date of writing, the Full-Stack JavaScript Track on Treehouse has undergone some really great changes since its initiation. If you learn well from a structured, somewhat linear path of courses, but also like the flexibility of being able to stop whenever and pick it back up, it may be a great option for you!
JS is so much more powerful nowadays than just being able to pop up alerts on your screen. The Treehouse Full-Stack JavaScript Track also covers JavaScript’s back-end, or server-side languages, such as Node.JS and AJAX. Ever been to a website that was able to dynamically update what you saw on the screen as you enter information or make selections, like Facebook? That requires a two-way open connection between the server (where information is being sent) and the client (the user’s computer, where they see the content change). Starting to see why all of this is important?
Careers Using JavaScript
JavaScript is a frequent mention on web development job postings, in its various forms. If you are looking for jobs in front-end web development, you will want to be comfortable with its browser-side capabilities, making things interactive and user-friendly. With back-end web development, many companies will want to see additional competencies in Node.JS and AJAX, allowing for fantastic and powerful user experience with dynamic content interaction. Or, as a full-stack developer, you may use both! Once you start to see what JS is capable of, you can decide to what extend you want to use it, and some projects will require more or less depending on the desired functionality of the end product.
Freelancing? Be sure to read up on valuations for each different product set, as your pricing model for browser-side JS will be very different from server-side.
Do you use JavaScript in your career, or with your clients? Feel free to weigh in on what you love and hate about it, and what you wish you had known in the comments! As always, you can also keep the discussion going on the La Vie en Code Facebook page, or via Twitter @lavie_encode. Happy coding!