This past week has been all about getting to know JavaScript. It has been interesting to learn this language because it is both familiar and strange. The syntax is all very similar to C, but the Object Oriented Grammar is very similar to S3 and S4 classes in R.
The first part I want to discuss this week. is some code that I was given. The code is HTML with embedded JavaScript.
<p id="demo"></p>
<script>
var price1 = 5;
var price2 = 6;
var total = price1 + price2;
document.getElementById("demo").innerHTML =
"The total is: " + total;
</script>
Code language: HTML, XML (xml)
After opening the HTML document, I could not spot any obvious errors. The code seems to run as expected. This code has three variables in it, price1
, price2
, and total
. Meanwhile there is a single object which is document.getElementById("demo")
.
Experimenting with Image Formats
The second part to this weeks assignment was working with images on the web. As an experiment I compressed an image into three different file types, PNG, GIF, and JPG. Before I converted them, I down scaled the original image in Photoshop to be 700 pixels wide, and then compressed it into each of the three formats. For each that asked for a quality, I put “Good.”
I found that the PNG had the best quality out of the 3 of them, and JPG was the worst. The JPG had large artifacts in areas with slight color gradients, while the rest of the image appears blurry. The GIF is a clearer image than the JPG, however the color feels like it has been put into a comic book. In large areas with a slight color gradient, artifacts are small and create hash like features in the image. Overall the GIF is not as clear as the PNG, but the colors look smoother than the JPG.
The GIF loaded the fastest, followed by the JPG, and last was the PNG. The PNG is 24 bit instead of 8 bit PNG, which has resulted in the higher quality and slower load times.
You can find the page I did this experiment at: http://simon-liles.epizy.com/Module3.html