Menu

Related Topics

HTML CSS JavaScript PHP Node.js React.js C C++ Go Rust Swift Python Java Excel MS Word PowerPoint
Search

JavaScript Data Types in Hindi

JavaScript Data Types क्या हैं?

JavaScript में Data Type यह बताता है कि किसी variable में किस प्रकार का data stored है। उदाहरण के लिए किसी variable में text store हो सकता है, किसी में number, किसी में true या false, और किसी में multiple values या complex information हो सकती है।

JavaScript एक dynamically typed language है। इसका मतलब है कि variable को declare करते समय हमें उसके data type को अलग से define करने की जरूरत नहीं होती। JavaScript runtime पर stored value के आधार पर उसके type को determine करती है।

उदाहरण के लिए:

let name = "Deepanshu";
let age = 20;
let isStudent = true;

यहाँ name में String, age में Number और isStudent में Boolean value stored है।

JavaScript में Data Types के मुख्य Categories

JavaScript के data types को सामान्यतः दो categories में समझाया जाता है:

Primitive types single और basic values को represent करते हैं, जबकि objects और arrays जैसे non-primitive types multiple या structured data को represent कर सकते हैं।

1. Primitive Data Types

Primitive data types JavaScript की basic value types हैं। JavaScript में commonly recognized primitive types हैं: String, Number, BigInt, Boolean, Undefined, Null और Symbol.

a). String

String का उपयोग text या characters को store करने के लिए किया जाता है। String को single quotes (' '), double quotes (" ") या template literals (` `) में लिखा जा सकता है।

JavaScript
Code copied!

ऊपर के example में तीनों variables में text values stored हैं, इसलिए इनका data type String है।

b). Number

Number data type का उपयोग numeric values के लिए किया जाता है। इसमें positive numbers, negative numbers और decimal values store की जा सकती हैं।

JavaScript
Code copied!

JavaScript में सामान्य numbers के लिए Number type इस्तेमाल होता है। इसी type में integer और decimal दोनों values आती हैं।

c). Boolean

Boolean data type में केवल दो possible values होती हैं: true और false। इसका उपयोग किसी condition, yes/no situation या किसी state को represent करने के लिए किया जाता है।

JavaScript
Code copied!

Boolean values conditions में बहुत useful होती हैं। उदाहरण के लिए किसी user का login होना या किसी product का available होना Boolean value से represent किया जा सकता है।

d). Undefined

Undefined तब मिलता है जब कोई variable declare किया गया हो लेकिन उसे अभी कोई value assign न की गई हो।

JavaScript
Code copied!

इस example में x को declare किया गया है लेकिन कोई value assign नहीं की गई, इसलिए इसकी value undefined है।

e). Null

Null एक special primitive value है जिसका उपयोग intentionally यह बताने के लिए किया जा सकता है कि किसी variable में अभी कोई meaningful object value नहीं है।

JavaScript
Code copied!

undefined और null को एक जैसा नहीं समझना चाहिए। undefined अक्सर उस situation को represent करता है जहाँ value assign नहीं हुई है, जबकि null को programmer जानबूझकर empty या absent value represent करने के लिए assign कर सकता है।

f). Symbol

Symbol ES6 में introduce किया गया एक primitive data type है। इसका उपयोग unique identifiers बनाने के लिए किया जा सकता है। अलग-अलग Symbol values एक जैसे description के बावजूद अलग unique values होती हैं।

JavaScript
Code copied!

ऊपर के example में दोनों Symbols का description "userID" है, लेकिन दोनों अलग unique values हैं। इसलिए comparison का result false होगा।

g). BigInt

BigInt का उपयोग ऐसे integers को represent करने के लिए किया जाता है जो JavaScript के सामान्य Number type की safe integer range से बाहर जा सकते हैं। BigInt literal के अंत में n लगाया जाता है।

JavaScript
Code copied!

BigInt को सामान्य Number के साथ सीधे arithmetic operation में mix नहीं किया जा सकता। जरूरत के अनुसार दोनों values को compatible type में convert करना पड़ता है।

2. Non-Primitive (Reference) Data Types

Non-primitive या reference values का उपयोग structured और complex data को represent करने के लिए किया जाता है। JavaScript में Object एक मुख्य non-primitive type है और Array तथा Function भी objects के रूप में व्यवहार करते हैं।

a). Object

Object related information को properties के रूप में store करने के लिए उपयोग किया जाता है। Properties सामान्यतः key-value pairs के रूप में लिखी जाती हैं।

JavaScript
Code copied!

Object में अलग-अलग properties को एक ही variable के अंदर organize किया जा सकता है। इससे related information को manage करना आसान होता है।

b). Array

Array का उपयोग multiple values को एक single collection में store करने के लिए किया जाता है। Array की values को index number के द्वारा access किया जाता है और indexing 0 से शुरू होती है।

JavaScript
Code copied!

यहाँ fruits[0] से Apple, fruits[1] से Banana और fruits[2] से Mango access होगा।

c). Function

Function reusable code का एक block होता है जिसे किसी particular task को perform करने के लिए बनाया जाता है। JavaScript में functions को variables में store किया जा सकता है और functions को objects के रूप में भी treat किया जाता है।

JavaScript

typeof Operator

JavaScript में किसी value का type check करने के लिए typeof operator का उपयोग किया जा सकता है। यह एक string return करता है जो value के type को बताती है।

JavaScript
Code copied!

typeof beginner level पर data type समझने और debugging में काफी useful operator है। ध्यान दें कि JavaScript में typeof null का result "object" आता है। यह language का एक पुराना historical behavior है; इसका मतलब यह नहीं है कि null वास्तव में एक object है।

Primitive और Non-Primitive Data Types में अंतर

Feature Primitive Non-Primitive / Reference
Data Basic single value Structured या collection-based data
Examples String, Number, Boolean, BigInt, Symbol, Undefined, Null Object, Array, Function
Complexity Generally simple values Complex structures को represent कर सकते हैं
Common use Individual values store करना Related या multiple values organize करना

Complete JavaScript Data Types Example

अब एक complete example देखते हैं जिसमें कई अलग-अलग JavaScript data types को एक साथ use किया गया है। आप नीचे दिए गए editor में code को change करके उसका output तुरंत देख सकते हैं।

JavaScript
Code copied!

Important Points

Conclusion

JavaScript Data Types यह समझने के लिए जरूरी हैं कि program में stored data किस प्रकार का है और उसके साथ किस तरह operations किए जा सकते हैं। JavaScript में String, Number, Boolean, Undefined, Null, Symbol और BigInt primitive types हैं, जबकि Object मुख्य non-primitive/reference category है और Array तथा Function objects के रूप में काम करते हैं।

Data Types की अच्छी understanding होने से variables, conditions, functions, arrays और objects जैसे JavaScript के आगे के concepts को समझना काफी आसान हो जाता है।


Code copied!

Page Views
0
Visit ID
Not tracked yet
Visit Time
-
Time on Page
0 seconds

Request


Leave a Comment


INITIALIZING...


INITIALIZING...


Quizzes in Hindi

GK Online Quiz in Hindi 10 pages
HTML Online Quiz in Hindi 10 pages
CSS Online Quiz in Hindi 10 pages
JavaScript Online Quiz in Hindi 10 pages
CCC Online Quiz in Hindi 10 pages
History Online Quiz in Hindi 10 pages



Comments Total: 0 comments

📰 Latest Articles

Total: 0 Articles

Featured Products

0 Products 0 Loaded 0 Remaining

All Products Loaded!

You've reached the end of our collection.

Contact Us Form