What is Javascript?

javascript

If you visit a website or use an app on your phone, there is a good chance that javascript is making it work. JS is one of the most widely used programming languages in the world. It is used with hypertext markup language (HTML) and cascading style sheets to make websites dynamic and interactive.

It is also used to create web applications, including social networks and search engines. Javascript is a high-level, single-threaded, garbage-collected, interpreted (or just-in-time compiled), prototype-based, multiparadigm, dynamic, object-oriented, event-driven, scripting language with a non-blocking event loop.

Unlike some other programming languages, javascript is not an Object-Oriented Language (OOP). Rather than using classes to define objects, javascript uses primitive data types to create structures with properties and methods that can be invoked by the programmer. This makes it easier for the programmer to write a program and keep the code organized.

The javascript language is very expressive. It has a very large set of built-in functions to perform operations such as math and string manipulation. It can also use a regular expression engine to perform pattern matching on strings. Lastly, it has a large number of reserved words that provide special capabilities. Examples include var, const, for, while and others.

A key element of the javascript language is its ability to travel through the element family tree (DOM) in the web page and access, modify, add or delete elements. In order to do this, the DOM must have been loaded by the browser interpreter.

Because javascript is so expressive, the code can be long and complex. To help with readability, developers often use comments to break up large blocks of code. Single-line comments are written after a double forward slash (//), while multiline comments are made up of curly braces.

As with any programming language, there are a few key concepts you need to understand before you can write and run javascript programs. These include values, variables and operators; expressions; functions; and events.

Values in javascript are represented as integers, floats and strings. Variables are containers for these values, as well as numbers, Booleans and boolean combinations. Operators are used to perform arithmetic and logical operations on the values. Expressions combine the values, variables and operators together to produce a new value.

Functions are reusable blocks of code that perform a specific task. JS supports a number of different types of functions, which can be invoked by the programmer with specific parameters. These functions are very powerful, enabling the programmer to build complex applications.

Events in javascript are triggered by user interaction, such as mouse clicks or keyboard input. They can trigger actions, such as changing the content of a web page or adding an event listener. They can also act on information from the DOM, allowing the application to change the contents of a document or even display documents in a different format.

The javascript language also supports multi-threaded programming, which means it can be used to perform multiple tasks at the same time. Typically, these tasks are queued up to run asynchronously and are then called by the main JS thread by the Event Loop. The main JS thread then waits for these calls to return the results of the long-running tasks.