⚠️ Malware / Trojaner / VirenGuardBreaker: Derailing AI-assisted malware analysis with a code comment(10.09.2026 um 11:00 Uhr)
⚠️ Malware / Trojaner / VirenAttack hides malware in PNGs and drops custom reverse tunnel on victims' machines(31.08.2026 um 20:26 Uhr)
⚠️ Malware / Trojaner / Viren33-hour BGP hijack of Softaculous traffic prompts security scramble(01.09.2026 um 14:04 Uhr)
🕵️ SicherheitslückenProlific Microsoft 0-day hunter drops CrowdStrike Falcon exploit PoC(03.09.2026 um 20:08 Uhr)
🔧 AI Nachrichten OpenAI commits $1B in AI credits to frontline cyber defenders(04.09.2026 um 01:47 Uhr)
⚠️ Malware / Trojaner / VirenGuardBreaker: Derailing AI-assisted malware analysis with a code comment(10.09.2026 um 11:00 Uhr)
⚠️ Malware / Trojaner / VirenAttack hides malware in PNGs and drops custom reverse tunnel on victims' machines(31.08.2026 um 20:26 Uhr)
⚠️ Malware / Trojaner / Viren33-hour BGP hijack of Softaculous traffic prompts security scramble(01.09.2026 um 14:04 Uhr)
🕵️ SicherheitslückenProlific Microsoft 0-day hunter drops CrowdStrike Falcon exploit PoC(03.09.2026 um 20:08 Uhr)
🔧 AI Nachrichten OpenAI commits $1B in AI credits to frontline cyber defenders(04.09.2026 um 01:47 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 3 Min Lesezeit
0

Zero (0) vs Null vs Undefined: Understanding the Differences

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

In programming, it’s common to come across 0, null, and undefined. These three values might seem similar at first glance, but they serve different purposes and behave differently in code. Let’s explore what each means and how they work, with simple examples.






What is Zero (0)?



The value 0 represents a number, specifically the smallest non-negative number. It is a defined value and is treated as a number in JavaScript.



Example:




CODE
let num = 0;
console.log(num); // Output: 0
console.log(typeof num); // Output: 'number'






Here, 0 is a valid number and can be used in calculations, comparisons, and other operations.






What is Null?



null represents an intentionally empty value. It’s like saying, “This variable has no value right now, but I’ve intentionally left it empty.”



Example:




CODE
let emptyValue = null;
console.log(emptyValue); // Output: null
console.log(typeof emptyValue); // Output: 'object' (this is a historical quirk in JavaScript)






Key point: You use null when you want to explicitly indicate that a variable has no value.






What is Undefined?



undefined means that a variable has been declared but hasn’t been assigned a value yet. It’s like saying, “This variable exists, but no value has been given to it.”



Example:




CODE
let notAssigned;
console.log(notAssigned); // Output: undefined
console.log(typeof notAssigned); // Output: 'undefined'






Key point: undefined is automatically assigned to variables that haven’t been given a value.






Comparing null and undefined with == and ===






Loose Equality ==



When you use ==, JavaScript performs type coercion, which means it tries to convert the values to the same type before comparing them.



Examples:




CODE
console.log(null == undefined); // true (because they both represent "no value")
console.log(0 == undefined); // false (0 is a number, undefined is not)
console.log(null == 0); // false (null doesn’t equal 0)









Strict Equality ===



When you use ===, JavaScript compares both the value and the type without any type coercion.



Examples:




CODE
console.log(null === undefined); // false (different types: object vs undefined)
console.log(0 === undefined); // false (number vs undefined)
console.log(null === 0); // false (object vs number)






You can get further details about == vs === by referring to this article LINK






Visualizing with Real-Life Example



Imagine you have three types of boxes:





  1. undefined box:




  • This is an empty box

  • Nobody has even tried to put anything in it

  • This “emptiness” happened accidentally/unintentionally





  1. null box:




  • This is also an empty box

  • But someone intentionally emptied this box

  • This is “intentionally emptied”





  1. 0 box:




  • This is not empty

  • This has a real value — which is 0

  • This is not “emptiness”, this is a number



That’s why:




CODE
// Both are empty boxes so they are equal
console.log(null == undefined); // true
// 0 is a box with something in it, so not equal to empty boxes
console.log(0 == undefined); // false
console.log(null == 0); // false









Conclusion



0 is a number and represents "nothing" in terms of quantity, but it’s still a defined value.

null is an intentionally empty value, often used to indicate that something has no value at the moment.

undefined means that a variable has been declared but hasn’t been assigned a value yet.

Happy coding!

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
GuardBreaker: Derailing AI-assisted malware analysis with a code comment
1 Quelle
Attack hides malware in PNGs and drops custom reverse tunnel on victims' machines
1 Quelle
33-hour BGP hijack of Softaculous traffic prompts security scramble
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Zero (0) vs Null vs Undefined: Understanding the Differences

Thematisch verwandte Begriffe: Zero, Null, Undefined, Understanding · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...