Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Use of Javascript [closed]

What is the main motto of using Javascript mostly. How it will be useful for developing Applications. I know Html. How it will help me in learning Javascript. Any relations to both JS and html.

like image 796
Gladiator Avatar asked Nov 27 '22 20:11

Gladiator


2 Answers

The main use of Javascript is that it allows you to make things happen in the user's browser without sending messages back and forth to the server. There are a variety of reasons why you might want to do this.

For example, sending a message to the server and getting a reply is a relatively long process: it is almost always a noticable time lag, and can take many seconds. Doing something directly in the browser can be much faster. So if, for example, you want to give the user an "invalid data" message of some sort, it can be much faster if it comes from Javascript.

In the same vein, with Javascript you can validate field-by-field rather than waiting until the user has completely filled out the screen and clicked a submit button. For example, suppose you present the user with a screen where he's supposed to enter transaction dates and monetary amounts. The user enters a whole screen full of these -- maybe 20 or 30 transactions -- and then clicks submit. If the user attempts to type dates in a format that you don't recognize, say typing day/month/year when you expected year-month-day, then with Javascript you could give him an error on the first unrecognizable date. With a round trip to the server, he'd have typed in a whole screen-full of invalid dates before you tell him he's doing it wrong.

Similarly, trying to do animation with round trips to the server would be unlikely to work, it would be way too slow. One way to do it would be with Javascript. (There are other ways, of course.)

like image 74
Jay Avatar answered Dec 19 '22 00:12

Jay


Javascript can be used for a multitude of different things.

When used alongside HTML in the browser, it can add some really cool dynamic and interactive features (compared with the historically static nature of HTML).

When used alongside a server-side engine like Node.JS, it can do just about anything any other server-side language is capable of.

like image 21
Justin Niessner Avatar answered Dec 19 '22 00:12

Justin Niessner