A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/interesting-facts-about-javascript/ below:

Interesting Facts About JavaScript - GeeksforGeeks

Interesting Facts About JavaScript

Last Updated : 06 Aug, 2025

JavaScript (often abbreviated as JS) is one of the most popular programming languages in the world. It is an interpreted, high-level programming language that follows ECMAScript. It powers interactive websites and is packed with amazing features that make it special and powerful.

Interesting Facts About JavaScript Here are some interesting facts about JavaScript JavaScript and Browsers Fun Features in JavaScript Numbers: 64-Bit Floating Point by Default

In JavaScript, all numbers (integers and floating-point values) are stored as 64-bit floating-point numbers based on the IEEE 754 standard. Unlike C++ or Java, there are no distinct int, float, or double types.

Bitwise Operations: JavaScript performs bitwise operations on 32-bit signed integers. So to do the operation it needs to convert 64 bit numbers.

JavaScript
let n = 5.5;           // Stored as a 64-bit floating-point number
let res = n | 0;    // Bitwise OR operation
console.log(res);     // Output: 5
Logical Operators Work with Numbers

JavaScript's logical operators (&&, ||, !) work with numbers and other types, not just booleans, treating falsy and truthy values as logical states.

JavaScript
console.log(0 && 5);
console.log(5 && 10);
console.log(5 || 0); 
Everything Is an Object (Sort of)

In JavaScript, Functions are objectsarrays are objects, and even primitive values can behave like objects temporarily when you try to access properties on them.

JavaScript
let s = "hello";
console.log(s.length);  

// Example with a number
let x = 42;
console.log(x.toString()); 

// Example with a boolean
let y = true;
console.log(y.toString());

/* Internal Working of primitives
   to be treeated as objects
   
// Temporary wrapper object
let temp = new String("hello"); 

console.log(temp.length); // 5

// The wrapper is discarded after use
temp = null; */
Arrays Are Objects

JavaScript arrays are technically objects, which allows them to have non-integer keys.

JavaScript
const a = [1, 2, 3];
a["key"] = "value";
console.log(a.key); 

In most languages, arrays are strictly defined structures and don’t allow such behavior.

Type Coercion

JavaScript has a unique way of handling types, often resulting in unexpected results

JavaScript
console.log(1 + "2"); 
console.log("5" - 2);

Output

"12"
3

This automatic conversion between types is called type coercion.

Hoisting

JavaScript moves declarations to the top of their scope before executing the code called hoisting. However, only the declaration is hoisted, not the initialization.

JavaScript
var greeting; // Declaration is hoisted to the top
console.log(greeting); // At this point, `greeting` is undefined
greeting = "Hello, World!"; // Initialization happens here
console.log(greeting); // Now, it logs "Hello, World!"

Output
undefined
Hello, World!

In Python or C++, referencing a variable before its declaration results in an error.

NaN Is a Number

In JavaScript, NaN (Not-a-Number) is actually of type number. It’s used to represent an invalid number, which can be confusing for beginners.

JavaScript
console.log(typeof NaN);
console.log(NaN === NaN); 
A character is also a string

There is no separate type for characters. A single character is also a string.

JavaScript
let s1 = "gfg";   // String
let s2 = 'g';    // Character

console.log(typeof s1); 
console.log(typeof s2);
Equality Quirks

JavaScript has two equality operators:

JavaScript
console.log(0 == "0");
console.log(0 === "0");

Output

true
false
Variables Without var

Declaring variables without var, let, or const automatically places them in the global scope. This can lead to unexpected behavior

JavaScript
function variable() {
    n = 10;
}
variable();
console.log(n); 

Output

10

But 'n' is now a global variable.

Related Topics

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4