Begin Web Programming with PHP & MySQL

Advertisements



Introduction to JavaScript

JavaScript is a client-side scripting language. JavaScript is an event driven language which is used mainly for increasing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript. JavaScript Can Change HTML Content in realtime. Most popular front-end frameworks used for creating web applications, React, Angular and Vue are based on Javascript.

JavaScript language has no concept of input or output. It is designed to run as a scripting language in a host environment, and it is up to the host environment to provide mechanisms for communicating with the outside world. The most common host environment is the browser.

JavaScript was once used only in the client side (browser), but node js (web server) has made it possible to run JavaScript on the server side.

How to Run JavaScript?

Being a scripting language, JavaScript cannot run on its own. In fact, the browser is responsible for running JavaScript code. When a user requests an HTML page with JavaScript in it, the script is sent to the browser and it is up to the browser to execute it. The main advantage of JavaScript is that all modern web browsers support JavaScript.

Difference between Java and Javascript

JavaScript and Java are similar in some ways but fundamentally different in some others. Both languages use C like syntax. The JavaScript language resembles Java but does not have Java's static typing and strong type checking. JavaScript follows most Java expression syntax, naming conventions and basic control-flow constructs.

  • JavaScript was created for making websites dynamic
  • No compiler is needed to run Javascript
JavaScript Java
JavaScript is a client-side scripting language. Java is an object-oriented programming language.
JavaScript code usually runs only on web browsers. Java applications can run on any virtual machine(JVM) or browser.
JavaScript file is saved with file extension “.js” and it is interpreted but not compiled. Modern browsers have built-in JavaScript interpreters to execute JS code. Java file is saved with file extension “.java”. Java uses a compiler to translate java programs into Java Bytecode, which can be executed by Java Virtual Machine.
JavaScript is integrated with HTML. Java is a Standalone language.
JavaScript is event based. Java is thread based.
JavaScript is a loosely typed language. It means you don't have to specify what type of information is going to be stored in a JavaScript variable in advance. Java is a strongly typed language.Java, requires you to declare a variable’s data type, such as int, float, boolean, or String in advance.