Penn Week 10a – Announcements, JavaScript Introduction, Small Group meetings

Announcements

  • Kozue Yamada will be our Fan Page guest critic on Monday.
  • We will have midterm meetings on Wednesday

 

Intro to JavaScript

JavaScript (JS) is a programming language that runs inside the internet browser. It was created in 1995. (HTML and CSS are not programming language – they set up style and structure rather than behavior).

Originally, it was used for front-end interaction. Now it’s also used for back-end. In general, you can use it to program the behavior of a webpage.

Before we can do anything fun with javascript, it’s important to understand the basics.

Console

The web console is a tool where you can write commands on a server directly into a webpage. In other words, it’s an easy way to test out javascript commands and see if they’re working.

To open it up, go to a website hold down command, option and J (⌥+⌘+J) or go to View / Developer / Javascript Console.

This is how it should look:
The javascript console is text only, and you can use it to communicate with the website using lines of codes.

Try saying “Hello” to the browser and see if it says anything back.

👎

Unless you’re using the correct syntax, you’ll likely see an error. Try this instead:
alert("Hello Friend!")

Now that you’ve made friends with your browser, you might be wondering what’s going on.
You’ve done 4 things:

  1. You called up the function, alert
  • alert(“Hello Friend!”)
  1. You utilized basic syntax, by starting with parentheses
  • alert(“Hello Friend!”)
  1. You typed a parameter
  • alert(“Hello Friend!”)
  1. You utilized basic syntax, by ending with parentheses
  • alert(“Hello Friend!”)

Parameters

You may be wondering what a parameter is. Parameters are what functions (such as the alert function) reference to know what to work on. Parameters can be a variety of different things. In our example, “Hello Friend” was the parameter, which is a string.

Data Types

Strings 

JavaScript strings are used for storing and manipulating text. A string can be any character, and it’s held inside double ""  or single quotes ''. It doesn’t matter which you use, but it’s best to pick one and stick with it.

When you defined the "Hello Friend!" string, you used double quotes and you typed 13 characters (spaces and exclamation points are all characters).

Examples:
"Wassup Penn"