 The first thing to understand about JavaScript is that it is not Java. JavaScript and Java are two totally separate languages. The confusion in the name stems back to the origin of JavaScript back in 1995 at Netscape, the makers of the first popular web browser Netscape Navigator. Brendan Eich was tasked with creating a new language that would be embedded in the browser, and he originally intended to call the language LiveScript, but the marketing people decided they wanted to write the coattails of this other new language called Java, which was also being embedded in the browser though in a different way. So Netscape and Sun, the creators of Java, reached a deal where Netscape could use Sun's trademark to call their language JavaScript. Originally, JavaScript was only implemented in the Netscape browser, but then Microsoft implemented it in their Internet Explorer browser, calling it JScript to avoid trademark infringement of the Java name owned by their rival Sun. A few years later, a standard for the language was created by a European standards body called ECMA, but they called the language ECMA script. So that's actually the official name for the language, but in practice everyone still just calls the language JavaScript. For most of its history, the vast majority of JavaScript code written has been written to run inside a web browser. The real reason JavaScript became popular at all is because it's been the only choice for code to run in all popular web browsers. For a long time in fact, the only JavaScript interpreters that existed were those inside the browsers. In recent years though, a few JavaScript interpreters have been created that run outside the browser and are beginning to pick up some use. For the first several years, JavaScript in the browser was used only to do very trivial things, largely because the JavaScript support in the various browsers was very uneven, creating lots of headaches to make JavaScript code run properly in all the different browsers. In the last decade though, people have begun doing more and more ambitious things with JavaScript in the browser as the major browsers continue to optimize and expand their support of the language. When you write JavaScript code to include in a web page, your code sees the content of the page as what's called the DOM. The DOM, standing for Document Object Model, is the hierarchy of objects that represent the content of the web page. We can access and manipulate the elements of the DOM using a set of standard functions included in the browser's JavaScript interpreter. User interactions with the page can trigger JavaScript code to run, and that code can then manipulate the page in any way desired. So we can do things like, say, change the color of some text on the page when the user clicks a picture. In this unit, we're not going to cover the DOM or JavaScript in the browser at all. We're just going to cover JavaScript the language itself. The basic data types in JavaScript are really all the same things we saw in Pigeon. The only difference is that what Pigeon calls lists, JavaScript calls arrays, and what Pigeon calls dictionaries, JavaScript calls objects. It must be said that JavaScript chose poor terms. The term array in predating languages refers to something similar to a list but not exactly the same, and the term object in programming is often used generically to mean any kind of value. So JavaScript is confusingly using object to refer to a specific kind of object, the kind which in other languages we call a dictionary or a map. In Pigeon, all of the operators are reserved words, but in JavaScript, as in most languages, most of the operators are symbols. The division operator, for instance, is a forward slash, and the multiplication operator is an asterisk. An even bigger difference with the operators is that, like most languages but unlike Pigeon, JavaScript uses infix notation, the style of notation most commonly used in mathematics. So here we see x times 3 plus 9. Both the multiplication operator and the addition operator are binary operators. They take two operands, one on the left and one on the right. The question here, then, is which of these operations is performed first? For example, in infix notation, the operators have an assigned order of precedence, and the multiplication operator in JavaScript has a higher precedence, so the multiplication is done first. If we were to explicitly enclose each operation in a pair of parentheses, we'd put a pair around x times 3, and then we'd put another pair around the addition operation. For comparison, if we were to write this in prefix notation, it would look like this. Function calls in JavaScript also use the notation more traditionally used in math, but the function precedes the parentheses and the arguments are separated by commas. So whereas in Pigeon we'd write paren fu abc nth paren, in JavaScript we'd write fu paren a comma b comma c nth paren. To call a function with no arguments, we'd simply leave the parentheses empty. Be clear that we specify the function of a call not just by name, but by any expression that evaluates into a function. In effect, you should think of the parentheses of a function called kind of like an operator itself, an operator that evaluates left to right. Here the function fu is called with arguments a and b, and fu itself returns a function which is then called with an argument c. If fu didn't return a function in this case, then the attempt to call it as a function would trigger an error.