Javascript: 101 Sign Up

Writing this post after watching the video below is the first task of signing up JavaScript 101. I knew about this video long time ago.

Only today, I really pay 100% attention on what Yahoo! JavaScript Architect Douglas Crockford say in Douglas Crockford - "The JavaScript Programming Language" 1 of 4.

This post is mainly about what I learned from this video. Here there are in point form:

  • Most of the JavaScript books are bad reference. He only recommended JavaScript: The Definitive Guide, Fifth Edition by David Flanagan, which is better reference.
  • Key ideas: load and go delivery, loose typing, objects as general containers, prototype inheritance, lambda, and linkage through global variable.
  • Value: numbers, strings, booleans, objects, null and undefined.
  • numbers: only one number type, which means there is no integer type and no floating point type.
  • NaN: it is a number. Remember that it does not equal to NaN.
  • null: it isn't anything.
  • undefined: default value for variable, parameters
  • Falsey value: false, null, undefined, "" (empty string), 0, NaN
  • Truthy value: "0", "false", object
  • All keywords are generally lower case.
  • == and != can do type coercion, so better use === and !== which do not do type coercion
  • Logical && is a guard operator. If first operand is truthy, then result is second operand, else result is first operand. For example, return a && a.member;
  • Logical || is a default operator. If first operand is truthy, then result is first operand, else result is second operand. For example, var last = input || nr_items;
  • Logical !! produces booleans value of truthy or falsey value. For example, !!"0" is true
  • Bitwise operators convert the operand to a 32-bit signed integer, and turn the result back into 64-bit floating point.

The second task is writing a simple JavaScript program which will print the sum of 2+2 and display the result in an alert window in the browser. I have to create an HTML page and put the JavaScript code within that page, so it executes when the page loads.



Comments powered by Disqus