In our previous blog, we discussed front-end development is done using HTML,CSS and Javascript. In this blog, we will explore the fundamentals of Javascript and how it demands site functionality.

Introduction:

Javascript is basically created/developed to make “web pages alive”. The codes/programs in this language are called as “scripts”. They can be written along the HTML code and it automatically gets executed when the page loads. The scripts can be executed as plain text and dont need special preparation or compilation to run.

Javascript can be executed not only in the browser but also on the server or in an device that has a special program called the javascript engine.

What can in-browser Javascript do?

Modern Javascript is a safe programming language. Javascript’s capabilities greatly depend on the environment its running. For example, Node.js supports functions that allow Javascript to read/write arbitrary files,perform network requests,etc…

In browser javascript can do everything related to web page manipulation, interaction with the users and webserver.

What can’t in-browser javascript do?

Javascript’s abilities in the browser are limited to protect the user’s safety. The aim is to prevent an evil webpage from accessing private information or harming the users data.

Any code editors can be used to write the program for javascript. maximum used will be the Visula Studio Code editor.

Code Structure:

Javascript codes can be inserted anywhere in the HTML document using the <script> tag.

The scripts can be either written inside the program as internal scripts or as a separate file and include them in the program called External scripts.

Example:

<!doctype html>

<html>

<body>

<script>

alert(‘Hello world!’);

</script>

</body>

</html>

This is the example of internal script.

External scripts can be included in the following format:

<script src=”script.js”></script>

Like all programming languages, JavaScript has a specific syntax for declaring variables, which can be used throughout the code. It supports various data types, operators (including mathematical and logical operators), loop statements, conditional statements, and functions.

Example:

<!doctype html>

<html>

<body>

<script>

function myFunction(p1, p2) {
return p1 * p2;
}

let result = myFunction(4, 3);
document.getElementById(“demo”).innerHTML = result;

</script>

</body>

</html>

Using javascript we can read files from server or save the data/information in the server. Lets discuss about that in next blog.

Conclusion:

In this blog, we got to know about the basics of javascript which helps in front end program.

Previous part:

Leave a Reply