DEV Community

Shirllie
Shirllie

Posted on

Introduction to Modern JavaScript

JavaScript is an object-oriented programming language that anables the dynamic behavior on most websites. Alongside HTML and CSS, it is a technology that makes the web run.

For example if you open any modern website you may interact with images and words that make the website user friendly which we call the user experience in general.

JavaScript uses functions and to create meaningful code together with HTML and CSS.

A function is a group of reusable code which can be called anywhere in your program. This eliminates the need of writing the same code again and again. It helps programmers in writing modular codes. Functions allow a programmer to divide a big program into a number of small and manageable functions.
Like any other advanced programming language, JavaScript also supports all the features necessary to write modular code using functions. You must have seen functions like alert() and write() in the earlier chapters. We were using these functions again and
again, but they had been written in core JavaScript only once.
JavaScript allows us to write our own functions as well. This section explains how to write
your own functions in JavaScript.
For example:
An anonymous function is a function without a name. An anonymous function is often not accessible after its initial creation.
The following shows an anonymous function that displays a message:
let show = function () {
console.log('Anonymous function');
};
show();
Code language: JavaScript (JavaScript)
In this example, the anonymous function has no name between the function keyword and
parentheses ().
Because we need to call the anonymous function later, we assign the function to the show variable.

Before we use a function, we need to define it. The most common way to define a function in JavaScript is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces.

Top comments (0)