traditionally used to create dynamic Web applications. It has zero relation to Java. Java is to JavaScript as Car is to Carpet. Recently, JavaScript has seen increased usage outside the browser (look up Node.js)
to use a feature called the console that comes with Firebug, a developer plug-in to the Firefox browser. The console allows us to execute some JavaScript code and see a result - it is the quickest way to experiment with JavaScript. You’ll learn how to include JavaScript in your Web pages in a Thursday session with Aidan and Kate.
large number of different data types - String, Integer, Decimal, Long, Boolean, Char, Date, etc. In JavaScript, there are much fewer data types: Strings (e.g. “Hello”) Numbers (e.g. 100, 3.14159, -139.30) Boolean (i.e. true or false) Object (everything in JavaScript is an Object)
special characters that you can use. For example, if you wanted to use a single quotation mark within a string that is enclosed by single quotation marks, you need to escape it. Example: var name = 'John O\‘Sullivan';
use to convert Strings to Numbers. To convert a String to an Integer use: parseInt("4982"); To convert a String to a floating-point decimal: parseFloat("3.1415926539");
parseInt, if you try to convert a string with a leading zero, you’ll see some very strange behaviour! console.log(parseInt("07")); console.log(parseInt("08")); Produces: 7 0
to a flaw in browser JavaScript engines where strings with leading zeros are converted into octal numbers rather than decimal numbers. Two ways to prevent this - use a radix: console.log(parseInt("08", 10)); Or, create a Number object instead: console.log(Number("08"));
to a Number using either parseInt or parseFloat, the result will be a special value “NaN”. This stands for “Not a Number”. You can check if something returns NaN using the following function: isNaN("blah");
we can use them to perform basic arithmetic. If you want to perform more complex mathematical equations, you can use the Math object. This contains functions max, min, round, sin, cos, tan and many more. Example: to get the sine of 90 degrees (90 deg = π/2) console.log(Math.sin(Math.PI/2));
true or false. You will use boolean logic a lot when you start building applications. We’ll see a bit more about boolean logic next week when we look at conditional statements. Example: var isMale = true; var isChild = false;
and Boolean variables as well as arrays and even functions! In the coming weeks you’ll learn about functions, arrays and object literals. * except null and undefined variables
Statements and expressions Conditional logic (if and switch statements) Iteration (for, while and do-while loops) And, If we have time: Working with objects Introducing arrays