Learning the JavaScript Machine

2 min read

var name = prompt("What is your name?");
alert("Hello " + name);

So while I go through the Fundamentals of Programming class at my two-year college, I am supplementing that knowledge with Lynda.com training. I am going through the Foundations of Programming: Programming Fundamentals (overlap, I know. I wonder if all programmers think this way about learning?) I am finding it a really great course with a guy teaching who pulls no punches. He talks about compilers and interpreters and it seems like ALL desktop languages need compiling. Web languages seem more flexible, being interpreters and cross-platform.

His language of choice to learn so far? JavaScript. It is a web language but it’s a scripting language that lives inside a program (like all scripting languages). I kind of wonder about AppleScript. I know you can write an AppleScript (kinda natural language syntax) to communicate between apps but does your script really live inside an app? Don’t know but I’ll probably figure it out sooner or later.

JavaScript is an interactive language, or, it can be interactive, making alerts and prompts, etc. The above code is a little script we worked on in the Lynda course.

We talked about variables and thanks to the creator of my favorite iOS workflow/Automator app Workflow, I have a solid grip on variables– just containers for data that you can reference again later in your code. I hear all the time about naming conventions– have to be careful as other people need to read your code and it needs to make sense to you and the program. It gets dicey. So up there the variable is named “name” because, well, it’s asking for a name. The prompt command brings up an interactive block where you can write your name, or anything else because the output is not dependent on the input. So you could put “shithead” and it will call up the variable name, and send an alert (another command):

Hello, shithead

See what it did there? Pretty cool.

Sometimes I really hate JavaScript dialog boxes but whatever. It works.

He got into the fact that if you have dependencies on the input, say a math function or an email, if you put

frm.txtDate ();

and you put “shithead” in the prompt, the tab will crash because it is dependent on a data object and not some random variable like name.

So yeah. Learning is fun but I’ve been about all day– class, the gym, etc. I am tired and at 12:15 am on the East Coast, I have to eat dinner. Can’t wait to get up and get working more on Lynda.

CC BY-SA 4.0 Learning the JavaScript Machine by Tiffany White is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.