Thursday, January 13, 2011

School of Webcraft: Javascript:101

The signup for P2PU and Mozilla's School of Webcraft has finally arrived and I am signing up for a Javascript:101 course. As a task to see who is ready to join the course we had to watch a video and complete a small assignment.

The video gave a history of Java, Javascript, and the process through which it became standardized. It seems that many companies played a part in the standardization and that because of this certain quirks and errors that are known problems still remain.

Some notes I took from this:

  • JavaScript is loosely typed
  • objects are dynamic, they are basically hash tables
  • Prototypal inheritance: objects inherit directly from other objects, not classes
  • Lambda functions are treated as 'first class' objects
  • Linkage through global variables. This can cause many problems and is often a security risk. Need to learn to mitigate this problem.
  • values:
    • number
    • string
    • boolean
    • object
    • null
    • undefined
  • NaN is the result of undefined or broken operations
    • NaN doesn't equal anything, not even NaN
    • It's type is number.
  • Javascript has a ton of unused reserved words.
  • != and == can cause type coercion, use !== and === instead as they give exact equality.
  • && and || are a bit different in js
  • Bitwise operators are slow in js.



I also had to produce a bit of javascript that pops up an alert showing the results of 2 + 2.

The code is as follows:

<html>
<head>
<script type="text/javascript">
function message()
{
var x;
x = 2+2;
alert(x);
}
</script>
</head>

<body onload="message()">

</body>
</html>

It produced the following results:

No comments:

Post a Comment