Javascript: 101 Week 1 Track 1

This post is a reply for the Javascript: 101 Week 1 Track 1.

Mainly answering questions for reflection and homework.

Reflection

  • Java was not suitable to be embedded in a browser because it need to be typically compiled and run on Java Virtual Machine (JVM). On the other hand, JavaScript typically relies on a run-time environment.
  • When using the parseInt() method, it is recommended to provide the radix as it stops at the first non-digit character and if the first digit is zero, it is allowed to interpret as octal constant, for example, parseInt("08") == 0.
  • Type is a way to represent the data in computer memory. It is useful in writing programs as it can be keep in the way as we want efficiently.
  • We lose precision when performing operations with decimal numbers in JavaScript because of the limitation of number representation in computer memory. It can be a problem when we are dealing money by dividing with odd number, such as 3.
  • The following operation produces the given result 115 * 4 - 4 + 88 / 2 = 500 as multiplication and division are calculating first before addition and subtraction. After multiplication and division, the equation will be 460 - 4 + 44.
  • The purpose of typeof 4.5 is to returning the type of 4.5 in string format, which is number in this case. On the other hand, typeof (typeof 4.5) will return string because typeof function is returning string type. There is not special type of data type in JavaScript.

Homework

Answer for exercises 2.1 - 2.6 from chapter 2 of Eloquent Javascript, please refer to Javascript: 101 Week 1 Track 2.

Example that shows a valid use of the 'guard' and 'default' operators in JavaScript.

References

Comments

Comments powered by Disqus