The first thing everyone learns in JavaScript

by Garrett Mickley | Last Updated: 2020-07-30

I’ve tried and failed to learn to program many times in my life.

I’ve spent thousands of dollars and hundreds of hours.

Enough is enough.

Now that I’m focused on privacy and OSINT, it’s time for me to really learn to program.

I have lots of ideas for tools to make my job easier.

Here I am learning Javascript.

I will also be focusing on learning Python in the future.

Right now I’m focused on Javascript.

The first thing everyone always learns is “Hello World.”

But I found three ways to write Hello World in Javascript.

I’m sure there are at least 100 more ways, but these three seem to be the three most important places to start.

All three will be used heavily throughout our lives programming.

If you’re brand new to programming, they’re called functions.

In JavaScript, we always end with a semicolon ;.

First, we start with console.log().

console.log("Hello World!");

The function console.log() is important because we will use it a lot for testing.

Having a message display in the console doesn’t modify the page at all.

We can have it return information to confirm our code works as intended, or return errors if it doesn’t.

Sometimes pieces of our code won’t have any other way of clearly displaying whether it’s working as intended or not.

We use console.log() to return messages with information in the browser console.

Just type console.log() and then, in between the parenthesis, add your message in quotes "".

Don’t forget your semicolon ; at the end.

console.log("Hello World!");

Play with it on Codepen (click the “Edit on Codepen” and then delete the // before the console.log() line):

See the Pen js hello world by Garrett (@quadiumstaral) on CodePen.

Next we move on to alert().

alert("Hello World!");

While we use console.log() to notify us, the programmer, of errors, alert() is one thing we can use to notify the user of an error.

The alert() function creates a small popup window with brief message.

Just like with console.log(), add your message in quotes "" between the parenthesis of alert().

And again, don’t forget your semicolon ; at the end.

alert("Hello World!");

Play with it on Codepen (click the “Edit on Codepen” and then delete the // before the alert() line):

See the Pen js hello world by Garrett (@quadiumstaral) on CodePen.

We close this lesson with document.write().

document.write("Hello World!");

The function document.write() is just one of the many ways to modify a web page with JavaScript.

It’s just as easy as console.log() and alert(), but it will make a visible change to the web page we are viewing.

Just like with console.log() and alert(), add your message in quotes "" between the parenthesis of document.write().

I keep repeating this because it’s a common problem people have: don’t forget to end with a semicolon ;.

document.write("Hello World!");

Play with it on Codepen (click the “Edit on Codepen” and then delete the // before the document.write() line):

See the Pen js hello world by Garrett (@quadiumstaral) on CodePen.

This has been pretty boring so far.

This is only the first post.

The first thing we’ve learned.

It will get better.

I’ll kick it up a notch for the next post.


Photo by Greg Rakozy on Unsplash

Journey with me

Retro glitch square

This blog has been a really long journey.

I don't have a fancy lead magnet for you.

No free ebook or checklist.

It's just a newsletter that follows my life journey.

Sign up for the newsletter to get updates on my life.

You will be added to the newsletter. I won't send you spam. Unsubscribe at any time. Powered by ConvertKit
%d bloggers like this: