Skip to main content

Command Palette

Search for a command to run...

JavaScript as a programming language

The evolution of JavaScript from a browser script to a global language.

Updated
10 min readView as Markdown
JavaScript as a programming language
M
Software Developer
💡
software is nothing more than data plus instructions.

What is the programming language?

Programming language is just a tool that allows us to write code that will instruct a computer to do something.

What is the JavaScript?

JavaScript is a high level language, which means that we don’t have to think about a lot of complex stuff such managing computer’s memory while it runs the program.

There are a lot of so-called abstractions over all these small details that we don’t want worry about. And this makes the language a lot easier to write and to learn.

It’s Object Oriented(Based on objects for storing most kind of data) and multi-paradigm(Can use different programming styles) language.

💡
JavaScript is case-sensitive

Popularity of JavaScript

Dynamic Typing

JavaScript has a feature called dynamic typing. It means when you create a new variable, you don’t have to manually define the data type of the value that it contains.

JavaScript automatically determines the data type of the value when it’s stored into a variable. In JavaScript that value has a type not variable.

💡
It’s simply mean that we can easily change the type of a value that is hold by a variable.

Programming Paradigms in JavaScript

JavaScript supports both imperative and declarative programming styles:

  • Imperative Programming : Focuses on how to perform tasks by controlling the flow of computation. This includes approaches like procedural and object-oriented programming, often using constructs like async/await to handle asynchronous actions.

  • Declarative Programming : Focuses on what should be done rather than how it’s done. It emphasizes describing the desired result, such as with arrow functions, without detailing the steps to achieve it.

💡
variable, data types, conditionals, loops, functions, and objects are the LEGO of any programming language.

Variables

Variable can be said as container / label to contain some value. To store some value in memory, the variable is used for it.

  • Variables can be declared using var, let, or const

  • JavaScript is dynamically typed, so types of values are decided at runtime.

  • You don’t need to specify a data type when creating a variable.

  • var (function and global scoped), let and const (local scoped).

  • var can be re-declared in the same scope, but let and const cannot be re-declared.

var x = 10;
var x = 20; // Allowed

let y = 30;
let y = 40; // SyntaxError

const z = 50;
const z = 60; // SyntaxError
💡
We can change the elements of array or objects even if declared as const. How? Because their reference is saved in stack while value in heap.
let name = "JS";

Rules for Naming Variables

When naming variables in JavaScript, follow these rules

  • Variable names must begin with a letter (A to Z or a to z), underscore (_), or dollar sign ($).

  • Subsequent (after that) characters can be letters, numbers, underscores, or dollar signs.

  • Variable names are case-sensitive (e.g., age and Age are different variables).

  • Reserved keywords (like function, class, return, etc.) cannot be used as variable names.

Data Types

It’s an attribute (quality) that identifies (recognizes) a piece of data and instructs (tells) a computer system on how to interpret (explain) its value is called a data type.

💡
Each data type has its own methods and operations that control how it can be used.

The data has type (e.g. number, string