Monday, January 17, 2011

Why Javascript and Javascript Basics 1

Some ability to web program would be quite useful. At first I thought to learn Java and did compile a few small and vary basic programs. The basic issue I'm seeing with Java is that I can't as readily utilize it because my sites would require a Java server which I won't always necessarily have available to me. JavaScript on the other hand doesn't require a special server and can run from any web page.

There is a free and quite excellent web course available on Javascript, Javascript 101 at P2PU School of Webcraft taught by Parag Shah. The course includes video lectures, programming assignments, blog posts about what has been learned, and quizzes.

This is my first assignment on a video lecture given by Douglas Crockford of Yahoo that covers what Javascript is, it's history, key ideas, and values. The remainder of this post will be a summary of Douglas Crockford's content from the lecture:

Javascript was developed in 1992. It's not Java but a separate and distinct programming language. It's small but very effective and sophisticated. There are 5 things that make Javascript distinct as programming language. First, it's programs are delivered as text in a webpage through a browser, which is the quality that makes me believe it's the ideal web programming language for me to learn. Other qualities are loose typing, objects as general containers, prototypal inheritance, Lambda, and linkage through global variables.

Values in Javascript are numbers, strings, Boolean, Ojbects, null, undefined, and Nan (undefined or an error). Numbers are are floating point so when doing arithmetic with decimals you must first multiple to remove the decimals. Number(value) converts a string to a number and putting the prefix + in front of a string does the same thing. Boolean value are true and false. False values include false, null, undefined, an empty string, 0, and Nan, which may be confusing.

In Javascript, any type can be used anywhere, that is any variable can have any type of value. Even a function can have a value. In Javascript, all keywords are lower case and it's case sensitive. Constructors begin with upper case. By convention, $ and underscore aren't used in Javascript. Javascript has a long list of reserved words.

There are two ways of putting comments in Javascript. Line comments begin with // and block comments are /* comment */. Operators are + - * / === < >, etc. The plus both does addition and concatenates.  The plus prefix also converts a string to a number, eg. + "42" returns 42. &, //, and ! are types of if then and if not statements that I have to go back over and will need to practice to fully understand. Hopefully the class will cover them in more detail later.

No comments:

Post a Comment