What can Javascript actually do?

As a web programmer or anyone generally interested in the web, one of the technologies you'll use or hear a lot about is Javascript

Lot's of people have their opinions on the language, some think it's a really lovely language, others genuinely dislike it.

While others debate on the numerous frameworks that make it beautiful; except angular of course...

It is genuinely everywhere in the web development ecosystem.

And its contentious reputation is clearly summed up by this tweet from Catalin Pit

Now, imagine my surprise when, a few days ago, a friend of mine asked me.

"What exactly is Javascript's use ?. I know it can manipulate objects in the dom but am I gonna learn a whole programming language just to change HTML Texts?"

Before looking at Javascript's capabilities, what exactly is it?

I'll give you a high-level definition.

Javascript is a scripting or programming language that allows you to implement complex features on web applications

So every time a web page or web app does more than just sit there and display static information for you to look at, -- displaying content updates, maps that are interactive, animated 2D/3D graphics, dancing buttons, scrolling videos e.t.c -- you can bet that Javascript is probably involved.

Javascript is primarily used to add automation, animations and interactivity to Web pages.

Web developers use JavaScript for anything from automating simple tasks to creating complex web pages that behave like desktop software applications.

JavaScript is also used beyond the Web in software, servers and embedded hardware controls.

In addition to standard programming language features, such as text manipulation and math calculations, JavaScript can access a wealth of information about the browser and the Web page it runs in.

JavaScript can use this information to write a custom greeting based on the time of day, add the Web page address in the page footer and optimize the Web page based on the browser you are using. Javascript can also update web page content on the fly.

Two important features give JavaScript the power to change a web page on the fly as you are interacting with it.

First, JavaScript is "event-driven," meaning it can respond to events such as mouse clicks, keyboard input, a Web page loading or a timeout being reached.

Second, JavaScript has access to the Document Object Model (DOM), an interface to the structure of a Web page. This gives JavaScript access to read and change images, text, form fields, styles, and other elements and attributes of a web page.

Events and the DOM interface allow JavaScript developers to perform practical tasks, such as validating form input, as well as add interactive features, such as image sliders and games.

Javascript can also communicate with the cloud

Using Asynchronous JavaScript + XML (Ajax), JavaScript can exchange data with a server.

This provides the potential to leverage server-side resources to build powerful Web applications.

With Ajax, JavaScript can access computing power, data and specialized server resources that are impractical or impossible to provide in a purely client-side application.

For example, Ajax can be used to create form fields that provide suggestions as you type, display search results without reloading the Web page, and provide interactive maps you can explore with a swipe of your mouse cursor.

Another exciting capability, however, is the functionality built on top of the client-side JavaScript language.

Application Programming Interfaces (APIs) provide you with extra superpowers to use in your JavaScript code.

APIs are premade sets of code that allow a developer to build or implement programs that would otherwise be hard or impossible to implement.

They do the same thing for programming that ready-made furniture kits do for homes

It is much easier to take ready-cut panels and screw them together than working out the design yourself, finding the correct wood, cutting all the panels to the right size and shape, finding the correct-sized screws, and then putting them together to make a bookshelf.

Javascript is, no matter how much it divides opinions, a super language. Hopefully, my friend gets to see it that way too.