${post.fImageName}

When did you start coding and why?

Leaders and trend-setters all agree on one thing: More people should learn to code! 

We asked 25 world leading web development experts about when they started coding - and why? Their stories might inspire more people to start coding. Here are the answers we got! (Add your story below)

1. Derek Sivers

derek.jpg
Writer, entrepreneur, TED-speaker, avid student of life. Follow on twitter: @sivers

“In 1994 I started making HTML websites. Just HTML. Not really programming.

In 1997 I made cdbaby.com - but it was still just HTML.

In 1998 I learned some PHP because cdbaby.com was growing and needed to be automated.

And then I just kept learning. Still learning every week. Right now learning Elixir and Elm.”

"In 1997 I made cdbaby.com - but it was still just HTML..."
- Derek Sivers (tweet this)


2. Douglas Crockford

douglas.jpg
Computer programmer & entrepreneur, best known for his involvement in development of the Javascript language.
Follow on Twitter: @doublascrockfor

“I was a broadcasting major, but in my first year I wasn't able to get into the studio classes. So instead I took a math class about FORTRAN programming.

At that time, computers were still multimillion dollar machines, so introduction to programming was through a university course.”

"At that time, computers were still multimillion dollar machines...."
- Douglas Crockford (tweet this)


3. Cory House

coryH.jpg
Founder of Bitnative, Pluralsight Author, MicroSoft MVP in C#, Creator of OutlierDeveloper, Speaker, Software Architect & Car Lover. follow on twitter: @housecor

“I have always loved cars, so my first experiment with coding was building a website about my car using Macromedia Flash. After successfully creating the site, I wanted to create an application that would allow other automotive enthusiasts to easily create their own websites, so I started studying programming to help me deliver the vision.”

"I have always loved cars, so my first experiment with coding was building a website about my car..."
- Cory House (tweet this)


4. Corinna Cohn

corinna.jpg
Expert full-stack JavaScript developer, website creator since 1995 & AngularJS expert.
Follow on twitter: @corinna000

“I had the great fortune of attending an elementary school equipped with Apple ][ computers. My first language was Applesoft BASIC and the first assignment I remember was to make a colorful picture on graph paper and to then carefully plot all the squares into a low resolution image using BASIC drawing commands.

I started coding professionally when I was on a technical support team. The product I supported was being cancelled and the only hope I had to keep my job was to learn Java. I spent a month cramming on Laura Lemay’s “Teach Yourself Java in 21 Days” and not only kept my job, but also established my career path.”

"My first language was Applesoft BASIC and the first assignment I remember was ..."
- Corrinna Cohn (tweet this)


5. Christian Johansen

christian.jpg
Coder at Kodemaker, speaker and author of Test-driven Javascript development. Active open source contributor and passionate death metaller in Execration.  Follow on twitter: @cjno

“I started coding in high school. A buddy learned to create websites with HTML. I thought it was cool and wanted to create websites with functionality - so I learned PHP.”

"I thought HTML was cool, but I wanted more functionality, so I learned..."
- Christian Johansen (tweet this)


6. Andrew Chalkley

Andrew.jpg
Web Development Technologies Expert Teacher, Hacker Monthly Contributor, Technical Writer & Co-Founder of Secret Monkey Science. Follow on twitter: @chalkers

“I started coding when I was about 14 or 15. I saw a group of friends hacking away on the MSDOS programming language QBasic. I suddenly realized that computers aren't just for word-processing, desktop publishing and spreadsheets, which was being taught at my school at the time, but can be used for more dynamic applications. Instead of just playing games, I could make them!”

"Instead of just playing games, I could make them.."
- Andrew Chalkley (tweet this)


7. Andrei Soroker

Andrei.jpg
Co-Founder & CEO of Sameroom, Pilot, Software Engineer & Speaker. Follow on twitter: @abs

“As an undergrad, I was studying Aeronautical Science at Embry-Riddle Aeronautical University -- it was a combination of flying and aviation-related academic courses.

Sophomore year, I decided to take a beginner C programming class as an elective (not sure why exactly). At the same time I was enrolled in Basic Aerodynamics, which included a wind tunnel lab. We had to record a ton of measurements off of pressure probes on an airfoil segment, at different angles of attack.

The goal of the lab was to calculate a bunch of numbers -- coefficient of lift, Reynolds number, and so on, per angle of attack.

I decided to write a C program to do this, and, after a few weeks of work, the program appeared to function. The numbers were within range, I got an A. I submitted the code of my program as proof of computation.

This experience changed the course of my career. I switched my major to CS and got a programming internship with a local company that manufactured a Linux-based monitoring gateway for old HVAC systems, enabling these dinosaurs to be accessible online. That's where I began learning to code -- a process that continues to this day!”

"This experience changed the course of my career..."
- Andrei Soroker (tweet this)


8. Alicia Sedlock

AliciaSed.jpg
Frontend Developer, Boston Chapter of Girl Develop It Teacher, Society of Grownups Web Developer & Purple Monkey Game Jam Co-Organizer. Follow on twitter: @aliciability 

“My initial exposure to programming was around 2003 or 2004, through making custom layouts for LiveJournal and MySpace (totally thought I would make money on this some day). This inspired me to take Intro To Web Development as a high school elective in 2005, where I started making Flash(!) websites for my friends' bands”

"My initial exposure to programming was around 2003 or 2004, through making custom layouts for."
- Alicia Sedlock (tweet this)


9. Bradley Holt

bradley.jpg
IBM Developer Advocate, Code for America Brigade Captain, Published Author & Speaker. Follow on Twitter: @bradleyholt

“I had the privilege of being able to first learn to code at the age of eleven or twelve. Our family had gotten a hand-me-down Apple IIc on which I learned to program BASIC from computer programming magazines (yes, that was a thing) and by reverse engineering programs that had come with the computer. Programming was fun for me as I enjoyed figuring out how things worked and being able to instruct the computer on what to do and then watch it carry out my instructions.”

"Our family had gotten a hand-me-down Apple IIc on which I learned to program BASIC"
- Bradley Holt (tweet this)


10. Brian Belhumeur

BrianBel.jpg
Craigslist Front End Engineer, JavaScript Developer, Web performance, JS/CSS/HTML. Follow on twitter: @jsartisan

“I started coding around 14 after I realized the awesome power of computers and wanted to harness it to help solve problems. I bought a book on C programming and using a shareware compiler starting making DOS games and tools. Even though they were simplistic at the time, I could see the potential. In high school, I wrote Visual Basic programs to do my math homework for me because that was WAY more fun (and educational) than doing the homework! To this day, the ability to build a tool that will help others is what keeps programming fun and interesting for me.”

"I started coding around 14 after I ..."
- Brian Belhumeur (tweet this)


11. Kimberly Blessing

kimberly.jpg
Senior Director of Technology and Web Development at Think Brownstone, Teacher at Bryn Mawr College Computer Science Department, Web Architect & Music Lover. Follow on twitter: @obiwankimberly

“I started coding when I started school, at age 5. My school had a computer lab full of TRS-80 Color Computers, which all of the students were introduced to. For whatever reason, something clicked, and I was hooked!

Later, in high school, I took a break from computers and programming, but when I returned to college and took a computer science course, everything fell right back in to place. Nowadays, I tell people that, for me, there’s something natural about expressing myself in code.”

"I started coding when I started school, at age 5..."
- Kimberly Blessing (tweet this)


12. Raymond Camden

raymond.jpg
Developer Advocate for IBM, lover of web standards, Star Wars, and good beer. Public speaker, blogger, and avid reader. Follow on twitter: @raymondcamden

“I started coding because I wanted to cheat in a computer game I was playing. That was the initial impetus. After figuring that out, I just wanted to learn about it more in general, but basically, it was games. (Oh, and Tron. I kid you not - Tron was a *huge* motivator for my coding passion.)”

"I started coding because I wanted to cheat..."
- Raymond Camden (tweet this)


13. Kent C. Dodds

kent.jpg
JavaScript engineer at PayPal. He hosts JavaScript Air, a live-video-broadcast podcast about JavaScript, and is the author of angular-formly. Follow on twitter: @kentcdodds

“I really started coding in September 2011 because I wanted to automate some monkey work I was doing at an internship. I was totally hooked when I discovered and started using JavaScript a year later.”

"I really started coding in September 2011 because I wanted to automate some monkey work..."
- Kent C. Dodds (tweet this)


14. Jack Franklin

jack.jpg
Developer Evangelist at @Pusher. Writes lots of JavaScript. Author of 'Beginning jQuery'. Writes at http://javascriptplayground.com . Google Developer Expert. Follow on twitter: @Jack_franklin

“I got started coding because I was asked to make a website for my football team, but the reason I stayed coding is because I've always liked solving puzzles and I see coding as just that. Whether it's an HTML / CSS layout problem or a complex code problem, I enjoy tackling difficult problems and coming up with elegant solutions which is why once I started learning to code I don't think I ever looked back!”

"I got started coding because I was asked to make a website for my football team..."
- Jack Franklin (tweet this)


15. Tracy Osborn

tracy.jpg
Author of @HelloWebApp. Creator of @WeddingLovely. Designer-developer-entreprenerd who loves being outside and climbing mountains. Follow on twitter: @limedaring

“I started coding in 2010 because I wanted to start my own startup. After failing to find a cofounder, I realized I needed to just build and launch a product myself.”

"I started coding in 2010 because I wanted to start my own startup..."
- Tracy Osborn (tweet this)


16. Volkan Özçelik

volkan1.jpg
Technical lead at Cisco, Expert at performance engineering, widgets, APIs, microservices, and JavaScript. Follow on twitter: @linkibol

When we asked Volkan about this, we got an answer so long that his effort deserved a post of it's own - read Volkan´s complete story here!

"I started coding at the age of 12 which makes 1991; it was a Commodore 64 that my uncle had given me as a present."
- Volkan Özçelik (tweet this)


17. Justin Searls

justin.jpg
Cofounder of Test Double, a software agency dedicated to making software that’s better for businesses to manage, developers to work with, and customers to use. Follow on twitter: @searls

“I was on a vacation with my family and the airline lost our luggage, so I was stuck in a beach condo in hot weather with only heavy winter clothes, my school backpack. I entertained myself for three days upon discovering my Casio calculator's BASIC editor, immediately addicted to the feedback loop of building a little game, handing it to my dad, and iterating on it. I didn't realize that counted as programming, but from then on I was hooked..”

"I was on a vacation with my family and the airline lost our luggage..."
- Justin Searls (tweet this)


18. Kyle Simpson

kyle.jpg
MakerSquare Head of Curriculum, Open Web Evangelist, JavaScript Expert, Author, Teacher, Speaker & OSS Contributor. Follow on twitter: @getify

“At age 11, my friend and I were playing at his house when we saw his dad (a programmer by profession) working in the den and we got curious about what he was up to. He typed for a minute and popped up a blue screen with a gray box (DOS, ascii text days) with my name in the middle of it, fascinating me and hooking me on programming from then on.”

"At age 11, my friend and I were playing at his house when we saw..."
- Kyle Simpson (tweet this)


19. Jonathan Stark

jon.jpg
Mobile Application Consultant, Best-Selling Technology Author, Software Developers Business Coach, Web Developer & Mobile Strategy Expert.  Follow on twitter: @jonathanstark

“I started coding around 1981-82 on an IBM PC (this one). I would have been around 13 at the time. I was utterly fascinated by using DOS and BASIC to make the computer do things - mostly stupid stuff like making little ascii animations and that sort of thing. I have no idea why I liked coding but it seemed like a natural outgrowth of my other interests (namely, scifi, video games, and D&D).”

"I started coding around 1981-82 on an IBM PC ..."
- Jonathan Stark (tweet this)


20. Léonie Watson

leonie.jpg
Paciello Group Senior Accessibility Engineer, Web Designer, W3C Web Platform WG Co-Chair, Writer, Foodie & Crime Fiction Junkie. Follow on twitter: @LeonieWatson 

"I used to play around with code examples taken from Apple magazine on my dad's Apple 2e back when I was a kid. I didn't start coding seriously until the early days of the web though, when I got bored on the tech support graveyard shift at one of the UK's first ISPs and started building websites to keep myself out of mischief!”

"I used to play around with code examples taken from Apple magazine on my dad's Apple 2e..."
- Léoni Watson (tweet this)


21. Josh Simmons

josh.jpg
Passionate Open Source web developer, author and sci-fi enthusiast at O´Reilly Media. Josh enjoys good music and excellent beer. Follow on twitter: @joshsimmons

“Eight year old Josh had wild ideas about how computers worked when my family got our first computer, but the reality was even more magical than I had imagined. I spent the next seven years moving from script kiddy to baby coder and the rest is history.

First it was macros and QBasic. My brother recognized my interest and picked up a copy of Visual Basic 6 for me -- being able to quickly build interfaces blew my mind, so you can imagine how thrilled I was to discover web development.

I was thirteen when a brave MUD made me an implementor and gave me access to my first *nix box and C code base. That's when I fell in love with open source and shifted over to PHP from ASP.

These days I do less coding and more community work, but the die has been cast. I'm an open source citizen and coder for life!”

"I spent the next seven years moving from script kiddy to baby coder and the rest is history."
- Josh Simmons (tweet this)


22. Shane Russell

shanee.jpg
Shane Russell is a developer-consultant and wanna-be designer at ThoughtWorks. He likes making things with CSS and JavaScript. Follow on twitter: @shanear

“I was bored one day and started building a website for my favorite TV show, Dragonball Z, using the Netscape Navigator website builder. (it's still up btw). I wanted to add a fighting game to the site, so I picked up "Javascript for Dummies" from my local bookstore, which started an almost 15 year love of coding.”

"I was bored one day and started building..."
- Shane Russell (tweet this)


23. Henrik Joreteg

henri.jpg
Progressive Web App developer, consultant, author, and educator. The web is the future of mobile and IoT. Follow on twitter: @HenrikJoreteg

“I got into coding because when I was in college, I knew I wanted to start a business and every interesting business I could think of to start was related to the web.


I tried to hire somebody to help me build what I wanted, but as a college student, I couldn't afford much. I decided to try to teach myself and ended up here: http://www.lynda.com/ColdFusion-8-tutorials/essential-training/433-2.html


I had no idea where to start, but that got me going and I was hooked!.”

"I tried to hire somebody to help me build what I wanted, but ..."
- Henrik Joreteg (tweet this)


24. Steve Kinney

steve.jpg
Steve Kinney is the codirector of academics and an instructor at the Turing School for Software and Design in Denver, Colorado. Follow on twitter: @stevekinney

“I started writing code relatively late in the grand scheme of things. I was 27 when I first tried to teach myself in earnest—and it was a long, hard road of some pretty bad code. Prior to that I had always wanted to code, but it was a tough nut to crack. I probably would have gone to a developer training program if they were around back then. I always wanted to learn how to program because I felt like it's a skill that allows you to kind of build whatever ideas you may have cooked up all by yourself.

I was working as a NYC teacher and there was this pretty terrible application that would spit out a wide variety of CSVs of student data: their state test scores, their predictive test score, their marking period scores, etc. But each CSV was its own little island. So, it was up to us to pretty much cut and paste columns from each CSV and align them with the unique student ID and then do brew up the Excel formulas to do figure out whatever it was that we wanted to know.

I didn't know how to program, but I'd been in vicinity of computers long enough to have a suspicion that this was something a relational database was better at doing than a bunch of over-worked teachers at the end of a long day. So, I volunteered to build an application that would take in all of the CSVs, parse them, and then pop them into a database. It was some gnarly code because I was brand new, but I was able to keep refining it and working on it and whatnot.”

"I started writing code relatively late in the grand scheme of things..."
- Steve Kinney (tweet this)

 


25. Stoyan Stefanov

stoyan.jpg
Facebook engineer, author of several javascript books, perfplanet calendar maintainer, writer, speaker and aspiring musician. Follow on twitter: @stoyanstefanov

“I knew some Basic and Pascal from school but I always planned to be a famous guitar player and computers didn't appeal to me. It wasn't until I discovered the Internet during the last months of college that I started: hm, web pages, how do you do this? HTML? OK, how about "rollover images"? JavaScript? Links that lose the underline on mouseover? CSS? Gotcha. "View Source" was my main teacher and inspiration. I also learned by using WISIWYG editors (Microsoft FrontPage, Netscape Composer) and studying the code they generate. My first project was a website dedicated to my girlfriend (now wife) and I threw every trick I leaned at it.”

"It wasn't until I discovered the Internet during the last months of college that I started..."
- Stoyan Stefanov (tweet this)


We hope the answers above will inspire you to share your coding story. We asked the same question on Quora. Over 100 people have commented. Add your story on Quora or in the comment field below.

We asked 25 world leading web development experts about when they started coding - and why?

Continue reading »

${post.fImageName}

Why did Volkan Özçelik start to code

We asked 25 leading programmers - when did you start coding and why. The answer from Volkan was so long so we thought it deserved a post of its own. Here's his answer to why he started to code.


Volkan Özçelik

volkan1.jpg
Technical lead at Cisco, Expert at performance engineering, widgets, APIs, microservices, and JavaScript. Follow on twitter: @linkibol

“The “when” part is pretty boring and common:

The “why” part is more interesting/internal/personal I think:

As a kid I was always different from the rest of the pack. — For instance, while others were picking up 20-30 page children’ story books to read on a summer holiday my choice of “light reading” was the Republic by Plato.

Even as a child I had two things that never left me even now: 1) an ravenous (and sometimes dangerous) level of curiosity and 2) an unstoppable desire to force myself to the limits, intellectually.

"I started coding at the age of 12 which makes 1991; it was a Commodore 64 that my uncle had given me as a present."
- Volkan Özçelik (tweet this)

I also was extremely logical, and I had a keen eye on causality. To give an example: Again around the age of 12, I learned chess by simply watching people play it for a couple of months; at the age of 14 I was beating my father in chess, who was a pretty decent player himself.

Also, as a kid, I would insist not to follow any rules that my parents set unless they give me a fair and reasonable explanation of why that rule was necessary. — Here’s an example of a particular torture that I made to my parents at every single rule they impose on me:

- Volkan, it’s 9, it’s bedtime now.
+ I should go to bed by 9? why?
- because you need to sleep to revitalize
+ but I can sleep later so why 10?
- because children sleep early.
+ aren’t there any children that sleep late?
- no.
+but I sometimes sleep late, ain’t it an exception then?
- well, yes, I guess.
+ then I’ll sleep at 11 today.
( and that would be the QED, unless they wanted to enjoy debating with me for an additional hour. — even as a kid I loved to find logical flaws in arguments; which then drew me to the field of philosophy, and skepticism, and logical fallacies )

Another thing was, I was obsessed with order (albeit being very clumsy).
Yet, I was also not afraid of variety. As long as the changes around me were deterministic, I was more than happy to adapt to them; to a child’s mind it was kind of finding chaos within the order.

So it was a combination of attention to detail, will to observe things, a desire to control all the things, constant will to push my limits and boundaries, and being a more logical than the average kid that you can find around was the perfect mix to make coding appealing to me:

When I was writing Basic on my Commodore (which was a hard job to do because I did not know English as a kid, and the program manual was in English, so I had to type in the commands exactly as they were in the manual, then run the program and then observe what happened. — with a few months of work, I was able to do IO, mathematical computations, and logical workflows in a language that I did not know a word of). In a year I was able to create a pong clone :)

So it was like I had my own little world that I could architect the way I wanted. — And needless to say, I was different than many of the kids around me, and understanding them was more challenging than understanding (back then, to me) the cryptic-looking basic language. — Because code was deterministic; humans were not.

I’m 37 right now, and I have been to quite a few managerial positions; and this fact has not changed: People are non-deterministic. — The only thing that changed, maybe, is in the 20-or-so-years, I learned to coordinate and communicate with people better. — I’ve learned that it all boiled down to communication. — And it was no different than programming in a sense. — Maybe more like programming a neural network, but the principles were kind of the same. — When I was communicating with a computer by writing a set of instructions but in the end of the day, the computer was listening to and interpreting the instructions. — and that was not different in humans either: communication was what the listener did. — That simple revelation took my entire adulthood to sink in :) — And learning and internalizing that, opened a lot of doors and opportunities to me — there is an undeniable value in communicating in the language of the party that’s going to interpret it."


Read what the 24 other world leading developers and programmers answered on the same question - when did you start coding and why.

We asked Volkan Özçelik when and why he started coding. Here´s the answer we got.

Continue reading »

${post.fImageName}

4 ways to drive your math teacher insane - JavaScript trolls

You can use any web browser on any computer (and tablet or smartphone) to prove it (scroll to the bottom of the article to find out more).

Here's the first out of four examples. They are all explained briefly for those interested. The explanations are not going into depth, they're just intended to give you a little information about the what's and why's. Links to more thorough explanations are provided for your convenience.

0.1 plus 0.2 is not 0.3

Adding the values 0.1 and 0.2 to each other will not result in 0.3 in JavaScript. Yes, you read right, do not believe your math teacher!

This code is checking if adding 0.1 to 0.2 will result in 0.3. JavaScript will answer yes (true) or no (false) when testing this. And to our surprise it says "no".

> 0.1 + 0.2 == 0.3
= false

[gif src="2016-gif-trolling/addition_part1"]

Tweet this gif

That's odd isn't it? Why did that happen? Isn't 0.1 + 0.2 the same as 0.3? Counting my fingers (parts of them) ... well, yes it is. Let's see what JavaScript thinks the result is.

> 0.1 + 0.2
= 0.30000000000000004

[gif src="2016-gif-trolling/addition_part2"]

Tweet this gif

Well now you at least see the reason behind JavaScript saying that the result is not 0.3. But why is it not 0.3? Keep reading.

Why did this happen?

Because of how JavaScript handles the storage of decimal numbers, it will not be absolutely perfect, but close enough. Computers don't really understand numbers and values, so it stores it in a pretty special way, but it's the only way for them to handle these values. It stores these values as something called floating points, so the exact representation for any number is never exact, it is "floating" as close as possible. It's never 100%, but in a real world case this would not give you problems because you'd always round that value down to two decimals, at most. Read a longer explanation on Quora.

The number 9999999999999999 does not exist

It's impossible in JavaScript to store the exact value of sixteen 9s. When doing so, in return you'll get 17 numbers back! Use sixteen 9s and it will magically get the value one added to it (+1).

I write var x = in the start to store my value, my number. The keyword "var" is short for "variable", something we use in programming for storing values. It's almost like algebra, letters that have a value. I then use a simple printing function - console.log() - to write back to me what was actually stored in the memory of JavaScript.

> var x = 9999999999999999;
> console.log(x);
= 10000000000000000

[gif src="2016-gif-trolling/16nines"]

Tweet this gif

The what now? I wish money worked this way, automatically adding. Keep reading to see why.

Why did this happen?

JavaScript cannot really store a number that high, so it does some cool things in the back to get this to work. The side effect is that it can only store every other number, like xxx982, xxx984, xxx986 and so forth. This is why xxx999 cannot be stored and it gets bumped up with one. Read more about the technicalities behind this on 2ality.

2 plus 3 is not always 5

Addition is not simply addition. From the early start in school you will learn that 2 + 3 is 5. But how come in JavaScript "2" + "3" is "23"? That doesn't make sense, right? Let's try this!

Examples

> 2 + 3;
= 5

[gif src="2016-gif-trolling/2and3_part1"]

Tweet this gif

> 2 + "3";
= 23

[gif src="2016-gif-trolling/2and3_part2"]

Tweet this gif

> 2 + +"3";
= 5

[gif src="2016-gif-trolling/2and3_part3"]

 

Tweet this gif

Wow, so many weird things going on here. What happened? But as you might have figured out, the quotation marks are the secret to this behaviour.

Why did this happen?

It's because of how JavaScript separates text from numbers. As it also handles text, and gives you the ability to join words together to form sentences, it "mistakes" the"3" to be the written text 3 and not the number/value 3. Well, "mistakes" is wrong to say, as this is the intended behavior of JavaScript and most other programming languages. The number 3 without quotes is a number that can be used mathematically, and "3" (with quotes) is just like any text and will be used to form longer words/sentences if used with the plus sign (+).

"Not a number" is still a number

This example is more related to the field of programming than math, but it can still be fun to try.

When working with JavaScript, you might want to test some user input to find out if it is indeed a number or not, like when they type in their date of birth. If the value is numeric, (like "1995" or "84") JavaScript will say "number", but if letters are inserted it will no longer be a number. JavaScript then reports it as NaN - Not a Number. In JavaScript we have a function that helps us test these kinds of things. We can send any data into it and it will give back to us information of the type it is - typeof().

> typeof(NaN);
= "number"

[gif src="2016-gif-trolling/typeofnan"]

Tweet this gif

So Not a Number is a number? That's as much sense-making as a ball being a cube, right?

Why did this happen?

Running this on the NaN ("not a number") you would expect to get "NaN" in return. But here is where JavaScript tricks you and returns "Number"! But it doesn't really trick you as this is standard behavior for any programming language. "NaN" is actually a number and part of how this is set up and meant to work. If you can only store numbers, but really need to "flag" that something is not a number, then you must store this flag as a valid number. So the computer scientists invented "NaN" for these cases. So "NaN" is a number, even if the meaning is "Not a Number". Makes sense now, right? Read more about it on Wikipedia.

Try the code yourself

You can - but don't have to - try all these examples yourself without any programming knowledge, and without any additional program. In the browser you are viewing this article, open what is called the developer tools (these might not be available on mobile).

In Chrome you can open this by right-clicking anywhere on a website and select "Inspect". This opens up a handy developer tool. In the top of that tool there are many tabs. Click the one labeled "Console". Here, at the bottom, you can type any code.

In Firefox you do the same; right click anywhere, select "Inspect", and then switch to the "Console" tab. The same goes for Opera, but there it's labeled "Inspect Element" when you right click.

If you are using Safari or Internet Explorer (or Edge) you'll have to find these tools yourself. But it's pretty much the same way, though some extra digging may be required, especially in Safari.

After typing any of the following code snippets in the console, just hit the enter key to run the code. So scroll back up and try some of them!

Closing words

There are a lot more fun and odd things going on with JavaScript than these few examples. Actually I'll do a follow-up post soon about this - quirks and fun facts about JavaScript.

If you'd like to know more about the language of JavaScript and how it came to be, check out this wiki about the JavaScript history.

All animated gifs in this article was recorded with LICEcap, and edited with the online tool EZgif.

* Make note that, per sé, your math teacher is not really wrong, it's just how JavaScript is built to handle some edge cases. Nonetheless, these are interesting and fun quirks!

The language of JavaScript has been around for a long time on the web. It does all sorts of different things, like calculations and animations. But did you know that it can also be used to make your math teachers pull their hair out? Here are four examples where JavaScript will "prove" your math teacher wrong!

Continue reading »