Automatically translated.View original post

null. nan. undefined

# Web Site Writing Basics

# javascript

# null_ nan _ undefined

The null variable in JavaScript is a value that represents no intentional value or that the variable does not point to any object.

Important characteristics of null

Data Type (Type): Although null means' no value ', when using the typeof operator with null, it results as' object ', a mistake that has occurred in the history of JavaScript and remains.

JavaScript

typeof null; / / The result is' object'

The Falsy: null value is considered a falsy value, which means that when converted to a boolean (boolean) value, the result is false.

Differences from undefinite:

The null is configured by the developer to indicate that the variable has no value.

Undefined means a variable has been declared but has not yet been configured or access to a property that does not exist.

Example of use

You may use null to:

Default value defined: requires the variable to start with a known 'empty' value.

JavaScript

Let selectedUser = null; / / The selected user does not have

Clear Reference Value: Remove references from objects to help with memory management.

JavaScript

Let data aObject = {name: "Alice"};

/ /....Use data aObject...

Data aObject = null; / / Clears references when this object is no longer needed.

Comparison

Comparison. Results. Notes.

Null = = undefined true Loose comparison (loose equality) assumes that the two are equal.

Null = = = undefined false A strict comparison (strict equality) assumes that the two have unequal kinds and values.

Null = = = null true -

null = = 0 false null is not equal to 0.

Null > 0 false -

Null > = 0 true When compared mathematically, null is often converted to 0.

Undefined in JavaScript is a value that represents a missing value. It occurs when a variable is declared but has not been defined by default, or when trying to access the property of an object (object) or a member of an array (array) that does not exist.

Important characteristics of undefined

Data Type (Type): The data type of undefined is' undefined '.

JavaScript

typeof undefined; / / The result is' undefined'

Falsy value: undefined is considered a falsy value, which means that when converted to a boolean (boolean) value, the result is false.

Differences from null:

Undefined is automatically the default value when the variable is missing a value (unintended).

Null is a value that the developer intentionally defined to indicate that the variable does not have a valid value or does not point to any object.

An example that causes undefined

Variables declared but without default:

JavaScript

Let name;

console.log (name); / / result: undefined

Access to properties not available in the object:

JavaScript

const user = {id: 101};

console.log (user.email); / / Result: undefined

The non-return function is clear:

JavaScript

greet (name) function {

console.log ('Hello, ${name}!');

/ / This function does not use the return command.

}

Const result = greet ('Alice');

console.log (result); / / result: undefined

Comparison

Comparison. Results. Notes.

Undefined = = null true Loose comparison (loose equality) assumes that the two are equal.

Undefined = = = null false A strict comparison (strict equality) assumes that the two have unequal kinds and values.

undefined = = = undefined true

NaN in JavaScript, short for "Not a Number" (not a number), is a special value in the JavaScript language that represents the result of a mathematical operation that cannot provide a valid numerical value.

Key characteristics of NaN

Data type (Type): Although it means "not a number," the data type of NaN is' number '.

JavaScript

typeof NaN; / / The result is' number'

Falsy value: NaN is considered a falsy value.

Cause of NaN

NaN usually occurs when you try to perform mathematical operations that do not make sense or cannot. Such as:

Dividing zero by zero:

JavaScript

0 / 0; / / Result: NaN

Mathematical operations on non-numeric values:

JavaScript

'Hello '* 5; / / Result: NaN

10 - 'World'; / / Result: NaN

Trying to convert a non-numerical value into a number:

JavaScript

ParseInt ('apple'); / / Result: NaN

Number ('oops'); / / Result: NaN

Comparison and investigation of NaN

The most important thing to remember about NaN is:

NaN is not equal to itself: this is a special feature of it that is different from other values in JavaScript.

JavaScript

NaN = = NaN; / / Result: false

NaN = = = NaN; / / Result: false

So to determine which values are NaN, you can not use the comparative operator (= = or = = =), but the specific function:

The isNaN () function: is a recommended way to determine if a value is NaN.

JavaScript

isNaN (10); / / Result: false (10 as a number)

isNaN (NaN); / / Result: true

isNaN ('Hello'); / / Result: true (because 'Hello' was tried to convert to a number and then got NaN)

The Number.isNaN () function: It is a more rigorous and better way to determine if a value is NaN without trying to convert a non-numeric value into a number (as isNaN () does).

JavaScript

Number.isNaN (NaN); / / Result: true

Number.isNaN ('Hello'); / / Result: false (because 'Hello' is not a direct NaN value.

2025/10/14 Edited to

... Read moreเวลาค้นว่า “undefined แปลว่าอะไร” ใน JavaScript ส่วนใหญ่คือเราเจอค่าประหลาด ๆ ตอน console.log หรือดีบั๊ก API แล้วไม่แน่ใจว่ามัน “ไม่มีค่า” แบบไหนกันแน่ ระหว่าง undefined, null หรือ NaN ซึ่งแต่ละตัวความหมายต่างกันและทำให้บั๊กคนละแบบ 1) undefined แปลว่าอะไร (ในมุมคนเขียนโค้ด) สำหรับฉัน undefined คือ “ยังไม่มีค่า/ระบบยังไม่ได้ให้ค่า” มักเกิดเองอัตโนมัติ เช่น - ประกาศตัวแปรไว้แต่ยังไม่ assign - อ่าน property ที่ไม่มีอยู่ - ฟังก์ชันไม่ได้ return ค่า ตัวอย่างที่เจอบ่อยมากตอนดึงข้อมูล: const user = { id: 1 }; console.log(user.email); // undefined แปลว่า key email ไม่มีอยู่จริง ไม่ได้แปลว่าเป็นค่าว่าง 2) สถานะ null คืออะไร null คือ “ไม่มีค่าโดยเจตนา” คือคนเขียนตั้งใจใส่เพื่อบอกว่า ณ ตอนนี้ไม่มีสิ่งที่ชี้ไป (เช่น ยังไม่เลือกผู้ใช้, ยังไม่มีผลลัพธ์) ฉันชอบใช้ null เป็นค่าเริ่มต้นที่ตั้งใจให้เป็น “ว่างแบบรู้ตัว” เช่น let selectedUser = null; ข้อควรจำที่ทำให้คนงง: typeof null ได้ "object" (เป็นบั๊กเชิงประวัติศาสตร์ของ JavaScript) ดังนั้นถ้าจะเช็ก null ให้ใช้ selectedUser === null ไม่ใช่เช็กด้วย typeof 3) เคส “0 null undefined nan” เกิดจากอะไร เวลาคุณเห็นค่าพวกนี้อยู่ด้วยกัน มักเกิดจากการคำนวณ/แปลงชนิดข้อมูล (type coercion) และค่า falsy - 0 เป็นตัวเลขปกติ แต่เป็น falsy - null เป็น “ตั้งใจว่าง” และเป็น falsy - undefined เป็น “ยังไม่มีค่า” และเป็น falsy - NaN คือผลลัพธ์ที่ “คำนวณออกมาเป็นตัวเลขไม่ได้” (ชนิดยังเป็น number) ตัวอย่างที่ทำให้ NaN โผล่: Number('hello') // NaN 0/0 // NaN 4) เปรียบเทียบให้ไม่พลาด: == vs === เวลาต้องเทียบค่า แนะนำใช้ === เป็นหลัก เพราะไม่เกิดการแปลงชนิดมั่ว ๆ - null == undefined เป็น true (เพราะกฎ loose equality) - null === undefined เป็น false อีกจุดที่ฉันเคยพลาด: เปรียบเทียบเชิงตัวเลข null >= 0 เป็น true แต่ null > 0 เป็น false เพราะตอนเปรียบเทียบเชิงคณิตศาสตร์ null มักถูกแปลงเป็น 0 ทำให้ผลดูแปลก ๆ 5) วิธีเช็ก NaN ที่ควรใช้จริง ห้ามใช้ NaN === NaN (จะได้ false เสมอ) ถ้าต้องการเช็ก “เป็น NaN จริง ๆ” ให้ใช้: Number.isNaN(value) เพราะ isNaN(value) จะพยายามแปลงก่อน ทำให้บางค่าดูเหมือน NaN ทั้งที่ไม่ใช่ NaN โดยตรง สรุปสั้น ๆ: undefined = ยังไม่มีค่า, null = ตั้งใจให้ไม่มีค่า, NaN = ค่าตัวเลขที่ไม่ใช่ตัวเลข (คำนวณพัง) และเวลาเทียบค่าให้ยึด === เป็นหลักเพื่อกันบั๊ก

Related posts

If null was in gorilla tag
It took me a long time
CHWAA

CHWAA

4 likes

Make sure you're in the right ✅️ before you do this 👌
Lildavoice

Lildavoice

3884 likes

A tablet displaying handwritten college statistics notes on a desk, covering topics like confidence intervals, hypothesis tests, and critical values, surrounded by study essentials.
Handwritten college statistics notes detailing how to find the margin of error, calculate confidence intervals, and use a Z-Value Cheat Sheet for various confidence levels, with calculator instructions.
Handwritten college statistics notes explaining how to find critical values for Z-tests, decide on null hypothesis rejection, determine p-values, and a table summarizing hypothesis test conditions and rejection regions.
steal my college stats notes! 💯📉📊
steal my college stats notes! 💯📉📊 hello friends! i just took a college stats class and got an A, so i wanted to share my notes with you :) usually students take college stats their first year, so i was a bit of the odd one out (as a junior). i ended up helping a lot of my peers with their
lia 💗

lia 💗

181 likes

Terminull Brigade Demo
Tried this. was definitely fun! #Terminullbrigade #gaming #tiktoklive
Ogilvie The Blue

Ogilvie The Blue

10 likes

5 Tips to not get overwhelmed when studying 🙇🏻‍♀️
1. Set timers for tasks: if you have multiple assignments or multiple things to study from (books, lectures, notecards) you need to schedule 45mins - 1 hr for each task and you will get it all done and now smash things in you can even do it in cycles 🔁 2. Take breaks : a little social media bre
Alexis Sanchez

Alexis Sanchez

45 likes

Adept Cosmetics RHNULL Palette 🖤
#makeup #eyeshadow #Shimmer #glitter #beauty
PoshLehr🖤

PoshLehr🖤

2 likes

Adept Cosmetics RHNULL Palette 🖤
#makeup #eyeshadow #glitter #Shimmer #beauty
PoshLehr🖤

PoshLehr🖤

7 likes

SAT but make it aesthetic. 😎
#study #sat #studywithme #viral #fyp
Jenny Study

Jenny Study

10 likes

Adept Cosmetics RHNULL eyeshadow Palette 🖤
#makeup #eyeshadow #Shimmer #glitter #newmakeup
PoshLehr🖤

PoshLehr🖤

18 likes

Rectangle body shape outfit formula 🥰
Preppylorax21

Preppylorax21

16 likes

damaged curly hair in its natural state !
My hair has no definition and lots of frizz when i don’t style my damaged hair but lately i haven’t been feeling like defining and finger coiling my curls to look uniformed. I’ve been putting a moisture milk/leave in, diffusing it 50% and letting it air dry throughout the day. i loveee how my hair
𝓙♡

𝓙♡

309 likes

ON A ROLL! USA Prime 15u Remains UNDEFINED- PBR 16u #youthbaseball #baseballcoach #fyp #MLB #mlbhighlights
Yoga with Kayla

Yoga with Kayla

0 likes

Duping $18,000,000 USD on the UN-DUPABLE Pay-to-Win Minecraft Server...
torque.test

torque.test

0 likes

These curlsssss😍 @UniceHairCo @UNice Hair and add these hashtag #unicehairwigs #unicebyebyeknotswig #byebyeknotswig #unicehair #knotlesswig #curlyhair#gluelesswig#curlywig#naturalhair
Aceofashanti

Aceofashanti

26 likes

Some of my favorites lately 💙🦋🐳🦕🫐
@vacationinc Classic Lotion SPF 30 @dieuxskin Deliverance Trinity Serum @summerfridays Jet Lag Mask @theoutset Ultralight Moisture-Boosting Oil @undefinedbeauty_co Sun Serum SPF 50 @belifusa Moisturizing Eye Bomb @laneige_us Toner + Moisturizer Let me know if you’ve tried any of these! ✨
Gabriela Yvonne

Gabriela Yvonne

321 likes

Replying to @nullwristmotion 8+ minimum #dayzonspam #relatable #real #dating #relationships
dayzonspam2.0

dayzonspam2.0

0 likes

using ✨GIRL MATH✨ to save money at Ulta 🫶🍋💄
hey y'all! so this morning I stacked a $5 off $25 purchase coupon + $11 in rewards + $38.50 on a gift card to purchase my Ulta cart for $15.26. I have been waiting for a good value gift with purchase to cash out and today it finally happened! I saw a post on IG about today's BEAUTY BREAK: F
kaylie gil

kaylie gil

426 likes

Big Baby - Undefined Series Cute Plush Blind Box Son. You can contact me if you need ☺️👍Pros :✨Outfit Details:
Blg baby blind box

Blg baby blind box

2 likes

If you have an undefined G center, you may relate. #humandesign #humandesigntiktok
BrandiYates | Human Design

BrandiYates | Human Design

2 likes

A list of Roblox games categorized into horror, random fun, obby/teamwork, and pet games, displayed over a blurred image of a person. The title reads "fun Roblox games you can play @thatsupercoolcatgirl" with Lemon8 branding.
☆ADDI☆

☆ADDI☆

1 like

Views of Guatemala
One of the best views on a trip I’ve seen in a while 😍 #guatemala #latinamerica #travelvlogger Guatemala ✈️ Guatemala City/Antigua ✨ Pros: very safe cities and easy to navigate 👀 Cons: aren’t many places to stay 🗺️ Tips: Spanish is more widely spoken so be sure to brush up on y
Natalie’s Travel Diaries

Natalie’s Travel Diaries

9 likes

I miss 2021 null
#nycdrill
DiamondNYC

DiamondNYC

14 likes

A woman in a brown two-piece crop top and wide-leg pants stands in a store, taking a mirror selfie. Shelves with various items, including socks, are visible in the background.
A woman in a brown two-piece crop top and wide-leg pants squats in a store, taking a mirror selfie. The background shows shelves with merchandise, including socks.
A woman in a brown two-piece crop top and wide-leg pants sits on a chair, adjusting her hair, taking a mirror selfie in a store setting with merchandise.
Love a 2Piece Set
TBT 1 year ago May 1st…. Outfit available on my Amazon.com Storefront. Link Below https://www.amazon.com/shop/undefined/photo/amzn1.shoppablemedia.v1.42b91b61-3c17-428b-8837-c044bb8dd398?ref_=aipsfphoto #amazonassociate #lemon8challenge #zerogatekeeping #casualstyle #StyleIns
Becoming Nic

Becoming Nic

4 likes

A woman in a black futuristic avant-garde outfit with sharp geometric patterns, exaggerated shoulders, and sleek pants. She wears rectangular sunglasses and stands against a black and white background. The image includes text: "Empower through fashion Dare to standout" and "lemon8 @soliasam."
Empower through fashion | Dare to standout
Fashion is not just about clothes, it's a statement, a declaration of power, and a form of self-expression! This look embodies everything my brand stands for - bold choices, breaking boundaries, and daring to be different! This futuristic avant-garde outfit features sharp geometric patter
Solia Sam

Solia Sam

4 likes

GG Mei
#overwatch #overwatch2
Null

Null

0 likes

Who is null and void?
I am them. They are 1. I am he. We have 1. #alonenotlonely #vocalcore #whoisnullxvoid #musicrecommendations #shareyourthoughts Atlanta
Null n Voyd

Null n Voyd

1 like

Why analysts should use Python for Data Processing
Hello Data Analysts! I wanted to highlight Python's efficiency in data cleaning and preprocessing. Python libraries like Pandas and NumPy offer methods to handle missing data, transform data types, and encode categorical variables like one-hot encoding. Tools such as drop_duplicates() ensure da
Yun Jung

Yun Jung

43 likes

🚩 Define The Relationship (DTR) 🚩
While situationships can feel fun and carefree at first, they often lead to frustration if one person develops deeper feelings while the other avoids commitment. 📝 Key Signs You’re in a Situationship 👀: 1️⃣ No Clear Labels 2️⃣ Inconsistent Communication 3️⃣ Plans Are Last-Minute 4️⃣ Physica
Margarita

Margarita

71 likes

Mama Nully
I promise I would trip you all as I run away uwu #vtuber #protectyou #twitch #twitchstreamer #envtuber
Nully/twitch streamer

Nully/twitch streamer

4 likes

A math cheat sheet explains solving quadratic equations by completing the square. It covers the general form, the final quadratic formula, a step-by-step method, and a detailed example with its solution.
This image illustrates the Decimal Shift Rule for multiplying and dividing numbers by powers of 10. It shows examples of shifting the decimal point right for multiplication and left for division.
The image defines number systems, presenting a hierarchy of numbers including natural, whole, integers, rational, irrational, and real numbers, with examples and number line representation.
math cheat sheet2
#mathstricks #mathtips #mathtricks #mathhacks #math @andrea35reiss
andrea35reiss

andrea35reiss

2 likes

A hand holds a light purple tube of a cleanser. The product highlights ingredients like Aloe, Niacinamide, and Green Tea. Text overlays on the image indicate it's a "Vegan Cleanser". The background shows a store aisle.
Vegan Cleanser 👀🤔🌿🫧
Absolutely love this cleanser from #undefinedbeauty It includes ingredients like Aloe and green tea🥰😍 This R&R Cleanser also includes niacinamide to gently cleanse, balance, tone, brighten and leave skin refreshed, soft and nourished. Not to mention this brand is Black-Owned…Pick it up at you
Ⓙ’тα𝓵ƴα💋

Ⓙ’тα𝓵ƴα💋

10 likes

BlankPain is inevitable,Misery is a choice,Love is undefined,But I miss your voi
Blank Pain is inevitable, Misery is a choice, Love is undefined, But I miss your voice, Change isn’t clarity, Clarity isn’t rare, I am still wondering, Do you still care, Faith is hopeful, Joy is missed, Patience is understated, When anger persists, Pray for me, My life is undoing,
Ari or Samaria

Ari or Samaria

14 likes

Fursuit Head Tour | Null v1.0
Tour of my first fursuit head build, highlighting some of the bells and whistles I think turned out pretty neat, including: ◾Swappable horns ◾Custom TPU base, horns, fangs, so on. It end up feeling sort of like foam. ◾Somewhat functional jaw, with glowing teeth. Its not perfect, but I might save
TOMB of NULL

TOMB of NULL

1 like

A laptop displaying a lesson on nouns and articles, with a notebook in the foreground, in a classroom setting. Overlay text reads 'HOW TO STAY ON TOP OF HOMEWORK college Edition'.
A laptop screen showing a Google search page with a vegetable-themed doodle and jellyfish background. Overlay text advises 'Do your HOMEWORK IN CLASS!' and explains the benefit of doing work in class.
A whiteboard filled with mathematical equations and notes in a classroom. Overlay text instructs to 'Make a list of everything that you have due soon' and to 'cross off whatever you finish!'.
How I stay on top of HW
Staying on top of my homework can be really hard sometimes especially since I’m the biggest procrastinator in the world. Here are some things I do to help get my homework done. - I always try to get as much work done while I’m physically in class as possible. I often find that I’m more motivated
natalie

natalie

275 likes

#movie #film #jackiechan #fyp #tv
di

di

0 likes

The app that saved my life🥰
#studytok #math #student #study #studywithme
maria15527

maria15527

0 likes

See more