What in the world is javaScript?

JavaScript is a programming language used in most modern websites. What does that mean? Programming, such as in javaScript, one of many languages, allows you to tell a computer what to do.

In a previous post, I showed you how HTML defines the structure of web pages and CSS is for design? That's all fine and dandy, but how do we make websites DO stuff? Stuff like opening popups and fancy animations.

What does javaScript look like?

This is where javaScript comes into play. A programmer embeds javaScript into the HTML telling the browser what to DO. javaScript is the only language (discounting HTML and CSS) that runs in a user's browser.

var elem = document.getElementById("test");
var pos = 0;
setInterval(function() {
  elem.style.top = pos + 'px';
}, 20);

This example grabs an HTML element called "test" and moves it 1px every 20 milliseconds, which results in a nice smooth animation.

The use of javaScript in so many websites raises security concerns as it can be used for various attacks, which is why some users turn off javaScript in their browsers. But sadly, many websites nowadays won't even load without javaScript.

Are Java and javaScript the same?

Oh, and for the record, Java and javaScript are not the same. Do YOU know the difference? Let me know in the comments.