JavaScript Icebreakers

Hey JavaScript, Tell me a bit about yourself!

JavaScript is one of the the primary coding languages in web development and allows sites to be dynamic, interactive, and enhances the user experience. It has a reputation of being extremely powerful, but challenging to learn for those who aren’t accustomed to thinking like programmers.

Prior to delving into my first JavaScript classes this week, I always had the same point reiterated to me: “be patient, it will take a while to wrap your head around it.” I didn’t quite know how the language worked, or what it’s exact role was, but I was very curious to figure it out. Who is this mysterious and perplexing character we call JavaScript? More importantly, what kind of awesome stuff can I build with it? Since JavaScript and I will be working together closely over the upcoming weeks, undoubtedly late into the night on most occasions, I thought we could start this off like any working relationship.

Hey JavaScript, tell me a bit about yourself! Here are five fun facts to help demystify JavaScript.

1. JS is a Californian in its early 20's

JavaScript was born in May 1995 under Netscape Navigator (remember them?), headquartered in Mountain View, California. Until the 1990s this city’s main economy was based on agriculture until it became (and still is) a significant hub for the tech industry with headquarters for companies like Google and Mozilla. Long story short, Netscape contracted programmer Branden Eich in 1995 to write JavaScript. At that time, Netscape saw a particular market opportunity to develop a language easy for web programmers to use, so Eich quickly wrote out the first version of JS in only ten days!

Now JavaScript appears in the vast majority of sites across the web, and is considered part of the three core languages of front end development along with HTML and CSS. JavaScript is also used to program beyond the web for a variety of things, including robots! Programming robots at 22 years old, not bad JavaScript!

2. JS is awesome at Math

Okay, maybe not the coolest hobby, but it’s pretty impressive! JS can instantaneously calculate basic math equations like addition (+), subtraction (-), multiplication (*), and division (/). Remember our old friend B.E.D.M.A.S. being drilled into our heads in math class? You can actually put it to use with JavaScript. For example, (2 * 3) + 4 will return 10, and 5 + (15 / 3) will return 10. You just have to write in the values in accordance with the B.E.D.M.A.S. rules and JS does all the math for you (because it just loves math-ing so much!).

JavaScript’s abilities with numbers allow for endless programming options, like for keeping score in a game or calculating prices. There are also built-in math functions like “Math.random” that generates a random number, and “Math.floor” that rounds a decimal number down to the nearest integer. You can even add text together to formulate sentences. For example, “Pizza is” + “ my favourite food” will return: “Pizza is my favourite food.” Side note: text values in JavaScript are always in single or double quotes and are called “strings.”

3. JS is a dog person

Seriously, it’s programmed to prefer dogs:

As you can see, in response to whether cats are greater than dogs (cats > dogs) JS replies “false,” and in response to whether dogs are greater than cats, JS replies “true.” What’s the deal JavaScript? Is it going to be a problem when I whip out my cat photos? ’Cause that’s what I usually do when I first meet someone…

Turns our there’s an explanation for this: JS isn’t saying that dogs are greater than cats, it’s just observing the alphabetical order of the first letters of the words and assigning a corresponding value. “C” for “cat” comes before “D” for “dog”, and therefore holds a lesser value.

4. JS is really sensitive (…case sensitive, that is.)

Just so you know, JavaScript is super sensitive, so you really need to be cautious of what you say. Whatever you tell JS (functions, keywords, variables, etc) will be precisely observed down to the letter capitalization. For example, if you told JS the value of getCoffee (var getCoffee = “get me one coffee please!”), it would have no idea what you meant if you asked it to “getcoffee”. The capital “c” in “getCoffee” is necessary for JS to remember the value. In addition to lettering, it’s sensitive to placement of commas, semi-colons, brackets, and the list goes on (we’ll leave those for another day, one thing at a time … please don’t cry, JS.)

4. JS’s thought process can get pretty philosophical

Take NaN (Not a Number), for example. NaN is a JavaScript value that represents an unrepresentable or undefined value. Oddly enough, when using the “typeof” operator to find out what type of value NaN is, JavaScript returns “number.” That’s right — “Not a Number” is a number.

There’s also the value of “null”, which one would assume means “nothing.” However, when you look up the value type, null is actually an object. “Null” represent an object who’s value is not know. Null is an object, and it’s value is “null.”

On top of NaN and null, there’s also the property of “undefined.” Undefined’s type is, well, “undefined.” A variable that has not been assigned a value is undefined.

And that concludes my icebreaker session with JavaScript. Happy learning!

Here we go, JavaScript…

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.