DEV Community

Cover image for 5 Things You Might Not Know About JavaScript
Dennis Morello
Dennis Morello

Posted on

5 Things You Might Not Know About JavaScript

JavaScript is a programming language that has been around for over 20 years. It's used in many different ways, but what are some things you might not know about it? In this blog post, we'll explore 5 things you might not know about JavaScript.

Original post at https://morello.dev/articles/five-things-you-might-not-know-about-javascript

Introduction

JavaScript has undoubtedly become one of the most essential programming languages in the world of web development. As the backbone of interactive web pages, it enables developers to create dynamic and engaging user experiences. You might already be familiar with the basics of JavaScript, but there are numerous lesser-known aspects and hidden gems within the language that can enhance your coding skills and expand your understanding.

In this blog post, we'll delve into 5 intriguing things about JavaScript that you might not be aware of. Whether you're ready to impress your colleagues with newfound JavaScript knowledge or simply eager to enhance your own programming prowess, this blog post is for you. Let's dive in and uncover the hidden gems that await us in the vast world of JavaScript!

1 - "JavaScript" is trademarked by Oracle

The name "JavaScript" is a trademark of Oracle Corporation in the United States. The trademark was originally owned by Netscape Communications Corporation, which created the language in 1995. In 1996, Netscape transferred the trademark to Sun Microsystems, which was acquired by Oracle in 2010.

A trademark is a legal protection that grants exclusive rights to use a particular word, phrase, symbol, or design to identify and distinguish a product or service.

As a trademark holder, Oracle has the authority to control the usage of the term "JavaScript" within the United States. This means that other entities must seek permission from Oracle or adhere to specific guidelines if they wish to use the term in a way that may be covered by the trademark. Unauthorized use of a trademarked term can lead to legal repercussions.

It is important to note that while the term "JavaScript" is trademarked by Oracle in the United States, the programming language itself is an open standard governed by the ECMAScript specification. This means that the language can still be used and implemented by developers and organizations globally, regardless of the trademark ownership.

In 2022, Node.js and Deno creator Ryan Dahl wrote an open letter titled Dear Oracle, Please Release the JavaScript Trademark, where he urges Oracle to release JavaScript trademark.

2 - JavaScript and ECMAScript are not the same thing

JavaScript is often referred to as ECMAScript, but the two terms are not interchangeable. JavaScript is a programming language, while ECMAScript is a standardized specification that defines the syntax, semantics, and features of the JavaScript language. It provides a standardized framework for implementing JavaScript across different platforms and browsers.

ECMAScript is maintained by Ecma International, an industry association, and undergoes regular updates to introduce new features and enhancements.

It is important to note that different versions of JavaScript correspond to different editions of the ECMAScript specification. For example, ECMAScript 5 (ES5) introduced significant improvements and features to the JavaScript language, while ECMAScript 6 (ES6) brought about even more significant changes, such as arrow functions, classes, and modules.

In summary, JavaScript is the widely used programming language that follows the ECMAScript specification. ECMAScript provides the standardization and guidelines for implementing JavaScript across platforms, ensuring compatibility and allowing developers to write code that can be executed consistently.

3 - JavaScript is a dynamically typed language

As in every programming language, in JavaScript variables and values have types associated with them. Although JavaScript is often referred to as a dynamically typed language, meaning that variables can hold values of any type, it does have a type system that determines how values can be used and manipulated.

JavaScript employs a loose type system, where type coercion can occur implicitly, allowing for flexibility in operations between different types. For example, the + operator can be used to add numbers or concatenate strings, but also to cast a value to a number.

There is also an operator called typeof that can be used to determine the type of a value at a given point in time. It returns a string representing the type of the operand.

4 - JavaScript has seven primitive types

As of ECMAScript 2020 release, JavaScript has seven primitive types, which are the building blocks of all JavaScript values:

  1. Boolean: Represents a logical value of either true or false.

  2. Null: Represents the intentional absence of any object value. It is a primitive type, but its sole value is null.

  3. Undefined: Represents a variable that has been declared but has not been assigned a value. If a variable is declared but not assigned a value, it is automatically assigned the value of undefined.

  4. Number: Represents numeric values, including integers and floating-point numbers. JavaScript uses the double-precision 64-bit binary format (IEEE 754) to represent numbers.

  5. BigInt: Introduced in ECMAScript 2020, BigInt is a primitive type that provides a way to represent arbitrarily large integers. It allows developers to perform operations on numbers beyond the limits of the Number type.

  6. String: Represents a sequence of characters enclosed in single quotes (''), double quotes ("") or backticks (``). Strings are used to store and manipulate textual data.

  7. Symbol: Introduced in ECMAScript 2015, Symbol is a primitive type that represents a unique identifier. Symbols are often used as keys in objects to avoid name collisions.

These primitive types in JavaScript are immutable, meaning their values cannot be changed once created. They are distinct from objects, which are composite data types that can store multiple values and have methods and properties associated with them.

Another property of primitive types in JavaScript is that they are passed by value. This means that when a primitive value is assigned to a variable or passed as an argument to a function, a copy of the value is created and stored in the variable or parameter, and any changes made to the variable or parameter will not affect the original value.

5 - JavaScript is a "compiled" language

In the context of JavaScript, the term compiled can be misleading. Unlike languages such as C++ or Rust, where the source code is directly transformed into machine code before execution, JavaScript goes through a different process. When a JavaScript program is executed, it is first passed through a just-in-time (JIT) compiler built into the JavaScript engine.

During the execution, the JavaScript engine performs several optimizations, including parsing the source code, optimizing the code based on various heuristics, and generating machine code or bytecode for efficient execution. This dynamic compilation process, performed by the JavaScript engine at runtime, helps improve the performance of JavaScript programs.

It is worth noting that the compilation process in JavaScript is different from the traditional pre-compilation step found in languages like C or C++. In JavaScript, there is no separate compilation step that generates an executable file beforehand. Instead, the compilation happens as part of the runtime execution.

Overall, while JavaScript can be considered a compiled language in the sense that it undergoes compilation during runtime, it is more accurate to describe it as an interpreted language with a just-in-time compilation process.

If you want to go deeper, Kyle Simpson explores this topic in detail in his book You Don't Know JS Yet.

Conclusion

JavaScript never ceases to surprise and fascinate developers with its hidden depths and lesser-known features. In this blog post, we explored five intriguing aspects of JavaScript that you might not have been aware of, expanding your understanding of this versatile language.

As you continue your journey with JavaScript, remember that there is always more to explore and learn. Embrace the ever-evolving nature of this dynamic language, and continue to discover new facets that will enhance your development skills.

Top comments (8)

Collapse
 
manchicken profile image
Mike Stemle

Quick note (not legal advice), in the United States, the failure to enforce a trademark or copyright often results in one no longer being able to assert those rights. Oracle hasn't enforced these rights, so if Oracle tried to sue someone for this they might actually have a difficult time, and their trademark rights may be lost completely.

Thankfully, Oracle is too busy doing things that add business value for themselves and their respective owners, so I don't think this is all that impactful.

Collapse
 
tauleshwar profile image
Tauleshwar Thakur

But still some tutors on YouTube got mails from Oracle for Using Javascript term in their videos

Collapse
 
manchicken profile image
Mike Stemle

Wild! Using a term in a video wouldn’t be a violation of trademark. Trademark law doesn’t grant a company exclusive right to the term or to describe the term or even advise on it.

There are a lot of dietitians who would advise you not to eat McDonald’s Big Mac. Both McDonald’s and “Big Mac” are registered trademarks of whatever holding company McDonald’s established to enforce and profit from their IP rights.

McDonald’s can’t go around telling dietitians to stop talking about their products or mentioning it.

All the Oracle trademark gives them the right to do is to tell someone that they can’t make a version of the language spec and call it “JavaScript.” Trademark is about preventing confusion in the marketplace, and establishing who gets to be to define the term, not being able to control the use of the term.

Thread Thread
 
tauleshwar profile image
Tauleshwar Thakur

Ya it's insane but seems to be happening since long time,
Hitesh Chaudary talked about this youtu.be/w6FbSbvYlp8

Thread Thread
 
manchicken profile image
Mike Stemle

In my 25 professional years I have seen a lot of legal malfeasance, Microsoft used to be one of the worst offenders (look up the term “Halloween Documents”). It goes back and forth. Oracle, however, has built a reputation for being one of the most litigious organizations. Most of the time people may be able ignore those types of C&Ds, but they really need an attorney who knows these things to advise them.

Since these folks are operating in commercial spaces, they should have attorneys, they’ll need them for a variety of reasons. These folks, however, aren’t being asked to stop their community activities, they’re being asked to stop their commercial activities. That is an important distinction that these “influencers” aren’t getting.

They are a business, and they are using another business’s trademark in their commercial endeavors for more than just a mention of the language. They need a legal department to help them

Thread Thread
 
tauleshwar profile image
Tauleshwar Thakur

Thanks for detailed explanation, as always there's two sides of the coin. I don't know how many peoples may get misguided, I think there should be more community talk about this and clarification is much needed for general awareness.

Thread Thread
 
manchicken profile image
Mike Stemle

No problem. The problem, in my view, is that we have companies who benefit from a culture of fear around intellectual property law, and a society that is willing to let that happen.

The law is supposed to protect everyone, and not to be used as a means of harassment.

Collapse
 
testerninja profile image
Tester Ninja

interesting by the way