This simple article explains what JavaScript is and what it is used for.
JavaScript
JavaScript is a dynamic, weakly typed language that is compiled at runtime. It can be executed as a part of the webpage in a browser (client side) or directly on any machine (server side). JavaScript was created to make webpages more dynamic and responsive.
How do web pages work?
When a user visits any webpage, a request is sent to the server from the client side (user or browser). And server sends a response in return consisting of a simple HTML file. When a user interacts with that HTML he might click the same button or simply interact with the web page again a request is sent from the user machine to the server asking for a reaction to the user's interaction and the server will again send some response in return. Now this is a very tedious task and to avoid this second request and response programmers came up with a language called JavaScript earlier known as LiveScript. When any user interacts with the webpage JavaScript dynamically changes the web page.
Some characteristics of JavaScript
- JavaScript is a dynamically typed language meaning a language that allows run-time modifications. Run-time modification is nothing but we can change the program while it is running
Weakly typed language means it does not require explicit specification of variables and objects
It can be used in browsers as a client-side language as well as a server-side language.
JavaScript is an interpreted language instead of a compiled one. he browser interprets JavaScript’s source code, line by line, and runs it.
JavaScript enables you to handle events and even generate custom events. For example, a user clicks on a button, and the system tells you to respond to the button click event with an action, say an information box.
JavaScript isn’t a compiled language, so it doesn’t get converted to byte code beforehand. Meaning it gets converted to bytecode just as it’s about to run. This enables JS to be lightweight. Even less powerful devices are capable of running JavaScript.
JavaScript is highly case-sensitive. All keywords, variables, function names, and other identifiers can and must only follow a consistent capitalization of letters. Here variables hit counter and hit counter are both different variables because of the difference in the case. Also, all keywords such as “var” are case-sensitive.
var hitCounter = 5 var hitcounter = 5
JavaScript is a functional programming language meaning functions enjoy similar behaviour from the JavaScript interpreter as that of objects or any other variable. we can pass them into arguments (pass by reference), return them by another function, and assign them to a variable as a value.