Introduction to JavaScript

Back to home
Logicmojo - Updated Aug 28, 2021

What is Javascript?

Javascript History

Brendan Eich of Netscape Communications created JavaScript in 1995. He was a co-founder of the Mozilla project, the Mozilla Foundation, and the Mozilla Corporation, as well as its chief technical officer and, for a brief time, its chief executive officer.

Javascript is a popular and frequently used programming language for developing web / mobile applications, real-time networking programmes, command-line tools, games, and other applications.

Javascript is a run-time compiled, dynamic, weakly typed programming language. It can be run through the browser or directly on any PC (host environment).

Dynamic: Javascript is essentially a dynamic language. While the system is executing, you can make changes to the different variables, as well as add new methods and properties to existing objects. Javascript is known for its dynamic behaviour, whereas most other languages are static, which reflects the precise use of Javascript.

Weak-typed: Javascript identifies the types of data in the programme, so the user doesn't have to specify the types of variables manually. For example, if we define a variable as let b = 'harry' javascript recognises the variable b as a String type one, and if we define a variable as a = 199, javascript recognises the variable an as an Integer type one. The Javascript assumes the data kinds, and we can subsequently adjust the initiation of variables a and b.

Javascript was developed to make online pages more dynamic and responsive, as well as to improve the usability of web services. A static website produced and designed using HTML and CSS would be insufficient to make a web page more interactive and appealing, which is where Javascript comes in.

Java Vs JavaScript?

Java and JavaScript are two entirely separate languages.

When JavaScript was first developed, it was known as "LiveScript." However, Java was highly popular at the time, and it is now the most powerful, popular, and complicated programming language, comparable to C and C++.

However, as JavaScript progressed, it became a totally independent language with its own specification called ECMAScript, and it no longer had any ties to Java. JavaScript, on the other hand, is a web programming language that runs in the client's browser.

JavaScript: Client-side Vs. Server-side

Client-side: The action takes place on the user's machine, which is referred to as client-side (Browser). Its programming includes a variety of coding, computation, results, animation, or any other type of intercommunication your website has with the user through a browser.

Server-side: The operation takes place on a web server, which is referred to as server-side. Its programming is limited to completing all jobs on the server. As a result, the user is apparently clueless of this.

Applications of JavaScript

Web Development: Static sites can be made more interactive and engaging by adding interactivity and behaviour. In 1995, JavaScript was created to accomplish this.

Server Applications: JavaScript was able to make the transition from client to server with the support of Node.js, and Node.js is the most capable server-side framework.

Games: JavaScript is useful not only in the creation of websites, but also in the creation of entertainment games. JavaScript is very popular in game creation due to its combination of JavaScript and HTML 5. It comes with the EaseJS package, which allows you to deal with rich graphics.

How JS execute the server-side?

JavaScript can now run not only in the browser, but also on the server, or on any machine that has a special programme called the JavaScript engine. A "JavaScript virtual machine" is a term used to describe the browser's installed engine.

At each stage of the method, the engine does optimizations. It even monitors the compiled script as it runs, understands the data it passes through, and optimises the device code based on that knowledge.

Engines are difficult to understand. However, the fundamentals are simple.

• The engine parses the script and reads data from its installed browser.

• The script is then compiled into machine language.

Limitations of JavaScript

Performance: Because a complicated application developed in JavaScript would be comparatively slow, it does not deliver the same level of performance as many traditional languages. However, because JavaScript is used to accomplish simple operations in a browser, performance is not a major concern.

Weak error handling: There is no need to specify the data type of the variable, hence it is a weakly typed language. As a result, build does not perform any type checking.

Complex: Programmers must have a full understanding of all programming principles, basic language objects, client and server-side objects to learn a scripting language; otherwise, it will be challenging for them to build complex scripts in JavaScript.

Hello World JavaScript Program

If you want to maintain your JavaScript code in the HTML document itself, use the script> tags (script> and /script>). This facilitates in the separation of your JavaScript code from the rest of the code in your browser. Because there are different client-side scripting languages (for example, VBScript), specifying the scripting language is strongly recommended. You must utilise the type attribute within the script> tag and set the value to text/javascript, as seen below:

<script type="text/javascript">

	<title>My First JavaScript code!!!</title>
	<script type="text/javascript">
		alert("Hello World!");

Conclusion: So there you have it, your first journey into the JavaScript realm. We've started with only an introduction to get you familiar with why you'd use JavaScript and what you can do with it.