Javascript

From OLSEncyclopedia

Jump to: navigation, search

Javascript is a scripting language commonly found embedded in web pages. It can do all sorts of useless things, and a few remotely useful ones as well.

The Shoutbox on our forums that you see if you're logged in is a huge mess of Javascript.

The important thing to note about Javascript is that the script is run on the client side, that is, in the individual user's browser. There are problems inherent with this, as users might not be using the browser you used to write and test the script. To further complicate things, different browsers handle the same things on pages differently with respect to Javascript, which results in most scripts that want to do anything remotely useful have a huge block of code dedicated to figuring out what browser it's running under and adjusting various things accordingly.

Javascript can also lead to a number of security hazards, so it is recommended that users disable Javascript in their browser and only enable it for select websites. The NoScript extension for Firefox makes this really easy.

Javascript's syntax itself is very similar to that of C++, with small exceptions. Variables are untyped, and you can create fun situations by treating a variable like it's one type in one place and a different type in a different place. There are no void functions (also sometimes referred to as subprocedures, since they perform a function but don't return a value), but the same effect can be accomplished by writing a function and just not having it return anything.

Lots of sites that have ad banners like to insert them into the page with Javascript, like they think it makes it harder to block the ad itself. Just disabling Javascript (or using the NoScript extension) can save you a headache on pages like that. Some pages will whine at you if you have Javascript disabled, because "oh teh noes they can't see our ads even though they wouldn't have ever clicked on them anyway so we're still making zero money off of them!"

Personal tools