TOP IMAGE
Resource Links
WARNING: Limited functionality mode due to unsupported browser

JavaScript

Updated on February 27, 2016

JavaScript is probably most known for providing advanced or dynamic features to web pages. Interestingly, my first exposure to JavaScript was in creating this web site, and based on my previous experience utilizing Python made the transition to using JavaScript very simple. Both languages share quite a bit in common including both of them being hybrid dynamically typed scripting languages that can utilize any combination of object oriented, procedural/structural, or functional programming paradigms at any time. Even some of the syntax is very similar; nonetheless, the main gotcha that I found when using JavaScript was references to variables passed into dynamically created functions later called by setTimeout(). The variables when the function was called would not reference the contents of the variable at the time of the setTimeout() call but whatever the variable was pointing to last; therefore, I utilized a feature of JavaScript called a Closure which allows you to generate a dynamically created function from within another function to provide a new local scope so the current values of any parameters/arguments can be preserved. Regardless, as much fun as JavaScript is to program in, Python seems to be a better language for larger scale applications. Not that it can't be done with JavaScript, but it is not as easy. In fact, there is a lot of discussion on the Internet about JavaScript in regards to scopes and in particular preventing the contamination or reliance of anything in the global scope which is easy to accidentally do in JavaScript. There is even concern about such things as undefined being redefined by other software preventing your code from operating correctly. I have not avoided its usage because I'm not pulling in any third-party software for my JavaScript, and it seems much clearer in regards to its usage. In addition, I utilize a JavaScript compressor that changes undefined to void 0 anyway. JavaScript compressors are typically utilized to optimize your JavaScript and/or reduce their size for faster loading, and the one that I'm using currently is Google's Closure Compiler.


To obtain more information on writing JavaScript, here are some of the references that I have used:


Copyright © 2016 Walter (All rights reserved)