Uses of JavaScript

Hello coders!

Just a quick question about the sues of JavaScript on the front end, I know React is very powerful and popular, but vanilla JavaScript - What is it’s actual uses on the front end, form validation, interaction/buttons etc?

Whatever you do with React: You’ll write it in Vanilla JS mostly. React provides you with a lot of hooks (functions), so you don’t have to write everything from scratch – but what you write will be mainly Vanilla Javascript plus HTML and CSS. There are a lot of things you do with Javascript, like:

  • Design features like page transitions, animations and design features that extend what you can already do with CSS
  • Form validations as you suggested
  • Anything interactive on a site like working with user input and do calculations or other manipulations with it
  • Retrieving data from an API

As alluded to above, React is a library/framework for JavaScript. Anything that React does, it does through JavaScript. Basically, React is translated into JavaScript whenever your app is built. Therefore, technically anything that React can do, vanilla JavaScript can do too.

However, anything requiring the management of state, which is the status of an app or an object, is very difficult and cumbersome to do with vanilla JavaScript. Most modern webpages/apps require managing and distributing state and its information, so engineers/developers created libraries and frameworks, like React, to make this process easier.

In other words, anything that can’t be done on the web with HTML/CSS is the realm of JavaScript, but we stand on the shoulders of (many) giants when we use frameworks and libraries to make our developer experience easier. If you ever hear that you don’t have to reinvent the wheel, this is an example of that idea in action. Mind you, people are constantly reinventing the wheel of web development by creating new frameworks, but in truth, no one wheel is perfect for every road.