An Introduction to Javascript

Ranjul Arumadi
Last Updated: May 13, 2022

Introduction

One of the most popular and powerful scripting languages ever. Javascript is easily a programming language developers adore.  From creating interactive web pages to developing web servers and awesome games, javascript is everywhere. In this blog, you will get an introduction to Javascript so that you can dive in and explore more possibilities out of it.

 

What is Javascript?

JavaScript is a cross-platform, object-oriented scripting language. Cross-platform means that the language is capable of working across multiple computing platforms. When we say Javascript is an object-oriented language, we mean that it follows a style of programming revolving around the concept of objects which can contain data and code. JavaScript is mainly used for web-based applications and web browsers. But as said in the introduction, JavaScript is also used beyond the Web in software, servers and embedded hardware controls.

 

Hello world in javascript

document.write('Hello, World!');

 

Output

Hello, World!

 

Javascript has a standard library of objects. These objects include Array, Data, and Math. it also has a core set of language elements. Operators, control statements, and statements make up the language elements. The core javascript can be modified to satisfy our requirements. 

 

Let’s say you want to use Javascript on the client-side and also on the server-side. For use on the client-side, we can extend the core Javascript by giving objects to control a browser and its DOM. DOM stands for Document Object Model. And to use Javascript on the server-side, we will have to extend the core Javascript by giving it those relevant objects for it to run on the server. In this way, Javascript can be used to change the way the webpage looks on the user-side and also respond to requests from code on the server.

 

Getting started with Javascript

There are quite a few ways to get started with scripting in Javascript. Some of them are-

 

1. Using the web browser console

You can run scripts directly from the browser using any web browser.

 

Steps:

  1. Open your favourite browser.
  2. Right-click on the page
  3. Select Inspect.
  4. ‘Elements’ tab will be active by default. Choose ‘Console’ right next to ‘Elements’.
  5. Enter javascript code here, followed by a semi-colon, and press enter.
  6. You can see the result right below your code.

 

Try these sample inputs:

console.log('hello!');

 

alert('Javascript is Awesome!');

 

Sample screenshot

Sample screenshot

 

2. Creating an HTML file

You can create an HTML file and include your javascript code in it.

 

Steps:

  1. Create an HTML file. Name it anything you want and give it a .html extension. Example ‘index.html’.
  2. Within the body, tags open the <script> tag and start writing your javascript code here. End it with a </script> tag.
  3. Double click on your file to see the output in your browser.

 

Example input code

<html>
<head>
    <title>My First Javascript Program</title>
</head>
<body>
<script language = "javascript" type = "text/javascript">
    document.write("Hello World!")
</script>
</body>
</html>

 

Output

Output screenshot

Why should you learn Javascript?

If you have tried to learn web development, you can observe that HTML is the language for building web pages. CSS is used for styling. What about Javascript?. Javascript is a language for programming web pages!.

 

If you are a student or a professional planning to look into web development, then Javascript is something you should be looking into. Let’s look at some of the benefits of learning Javascript.

  1. Javascript can help you create beautiful and functional websites. This will give the users a great experience when they visit your pages.
  2. Cut down your development time. Javascript has many frameworks and libraries, which can drastically change the way you create things. These frameworks and libraries can save your time and improve your productivity.
  3. It is one of the most popular programming languages adored by the whole world. You can use it for front end development, back end development, game development etc. The possibilities are endless.
  4. Javascript is everywhere. It comes pre-installed on every web browser. This makes it very easy to learn Javascript, and you need not bother about having to install a lot of things to get started.  
  5. Finally, Javascript developers are always in demand for industries. If you learn and practise Javascript well, you could very well land a great job with great pay.

 

JavaScript and ECMAScript

You must have come across words like ECMA, ECMAScript etc. when you started researching Javascript. Let’s try to simplify these things. To put it in simple terms, ECMA International is an organization that creates standards for technologies. Not laying down standards can be an issue for a lot of things. ECMA-262 is a standard published by ECMA International. This publication lays down the specifications for general scripting languages. Javascript is a language that conforms to the ECMAScript specifications. 

JavaScript and Java

One significant confusion students face while starting with Javascript is that they think it might be similar to Java. This, however, is not true. Let us see some differences between Java and Javascript.

JavaScript

Java

  1. Javascript is a scripting language.
  1. Java is a programming language.
  1. Javascript is run in the browser and on servers using Node.js.
      2. Java can create applications that can run in virtual machines or browsers.
  1. Javascript code is all in text.
      3. Java code needs to be compiled
  1. Weakly typed language
      4. Strongly typed language.

 

Frequently Asked Questions

  1. What is Javascript?
    Javascript is a high-level scripting language for the web.
     
  2. What is the use of Javascript?
    Javascript is most commonly used in creating web pages. It is also used for building apps, games, servers etc. 
     
  3. Is it easy to learn javascript?
    Javascript is a beginner-friendly language and is easy to learn. Javascript has a wide variety of applications, and learning it would be a good investment. 

 

Key takeaways

Javascript is a popular and powerful scripting language. It is most commonly used for the creation of web pages however it has many other applications. It is very easy to start learning javascript, and all you require is a web browser and a text editor. Javascript is a language that conforms to the ECMAScript specifications. 


Already excited?. Learn Javascript from top courses provided by Coding Ninjas like ‘Starting with Javascript’. Want to go full-stack with Javascript?. Check out Full Stack Web Development Course with Node.js + HTML/CSS/JS offered by Coding Ninjas. These tutorials and courses will help you learn and master Javascript so that you can become a ninja in it!.  

Was this article helpful ?
5 upvotes

Comments

No comments yet

Be the first to share what you think