DEV Community

Cover image for Main features of JavaScript programming language
Tomek Skupiński
Tomek Skupiński

Posted on • Edited on • Originally published at blog.thecode.xyz

4 3

Main features of JavaScript programming language

JavaScript is a high-level interpreted programming language. It is a language that is also characterized as dynamic, weakly typed, prototype-based, and multi-paradigm.

History

JavaScript was originally developed by Brendan Eich in 1995 while he was working for Netscape. It was originally called LiveScript but was renamed to JavaScript in order to capitalize on the popularity of Java. The language was standardized in the ECMAScript language specification in 1997.

Usage

JavaScript is used in conjunction with HTML and CSS to create web pages and web applications. It can be used to add interactive features to web pages, such as games, form validation, and animated graphics.

JavaScript is also used for server-side programming with technologies such as Node.js. This enables JavaScript to be used for developing web applications and server-side applications.

Features

Some of the features that make JavaScript unique are:

  • dynamic typing
  • prototype-based inheritance
  • first-class functions

Dynamic Typing

In JavaScript, variables are not statically typed. This means that you don't have to specify the data type of a variable when you declare it. The data type of a variable is determined automatically based on the value that is assigned to it.

For example, the following code declares a variable without specifying a data type:

let foo;
Enter fullscreen mode Exit fullscreen mode

The data type of the foo variable is automatically set to undefined. However, if we assign a value to the foo variable, the data type will be automatically set to the type of the value:

let foo = 42; // foo is now a Number

let foo = 'bar'; // foo is now a String

let foo = true; // foo is now a Boolean
Enter fullscreen mode Exit fullscreen mode

This dynamic typing is one of the reasons why JavaScript is a very flexible language. It allows you to write code without having to specify the data types of variables upfront.

Prototype-based Inheritance

In JavaScript, inheritance is implemented using prototypes. A prototype is an object that defines the properties and methods for a class of objects.

When you create a new object, you can specify its prototype. The new object will then inherit all the properties and methods from the prototype.

For example, let's say we have a Person prototype with a name property and a sayHello() method:

function Person(name) {
  this.name = name;
}

Person.prototype.sayHello = function() {
  console.log('Hello, my name is ' + this.name);
};
Enter fullscreen mode Exit fullscreen mode

We can then create a new Person object and call the sayHello() method:

let john = new Person('John');

john.sayHello(); // Hello, my name is John
Enter fullscreen mode Exit fullscreen mode

As you can see, the john object inherits the name property and the sayHello() method from the Person prototype.

First-class Functions

In JavaScript, functions are first-class citizens. This means that they can be treated like any other value in the language.

For example, you can assign a function to a variable:

let foo = function() {
  // do something
};
Enter fullscreen mode Exit fullscreen mode

You can also pass a function as an argument to another function:

let bar = function(foo) {
  // do something with foo
};

bar(foo);
Enter fullscreen mode Exit fullscreen mode

And you can return a function from another function:

let baz = function() {
  return function() {
    // do something
  };
};

let qux = baz();

qux(); // this will execute the function that is returned from baz()
Enter fullscreen mode Exit fullscreen mode

Because functions are first-class citizens in JavaScript, they can be used in a wide variety of ways.

Summing up

These are just some of the different JavaScript language features and characteristics. JavaScript is a powerful and popular language that is used in many different ways. Explore the different features of JavaScript to see how you can use it in your own programs.

Image of Stellar post

How a Hackathon Win Led to My Startup Getting Funded

In this episode, you'll see:

  • The hackathon wins that sparked the journey.
  • The moment José and Joseph decided to go all-in.
  • Building a working prototype on Stellar.
  • Using the PassKeys feature of Soroban.
  • Getting funded via the Stellar Community Fund.

Watch the video 🎥

Top comments (0)

Image of Stellar post

🚀 Stellar Dev Diaries Series: Episode 1 is LIVE!

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

👋 Kindness is contagious

Dive into this insightful write-up, celebrated within the collaborative DEV Community. Developers at any stage are invited to contribute and elevate our shared skills.

A simple "thank you" can boost someone’s spirits—leave your kudos in the comments!

On DEV, exchanging ideas fuels progress and deepens our connections. If this post helped you, a brief note of thanks goes a long way.

Okay