JavaScript Data Types In Hindi

📔 : Java Script 🔗

JavaScript dynamic type language language है means किसी variable को initialize करते समय हमें इसमें assign की गयी value के type को declare नहीं करना पड़ता है , जिस भी तरह की हम value assign करते है JavaScript Engine इसे automatically convert कर देता है।


javaScript Data Types

JavaScript में use होने वाले data types इस प्रकार हैं -

  1. Number
  2. Bigint
  3. String
  4. Boolean
  5. null
  6. Undefined
  7. Object

JS Number

JavaScript में integer या floating points दोनों तरह के लिए same data type number ही है

Another File : js_number.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Data Type : Numbers</title>
  </head>
  <body>
    <script>
      let x = 10;
      let y = 10.78;
      document.write('type of x : '+ typeof x + ' and type of y : '+ typeof y );
    </script>
  </body>
</html>
Output
type of x : number and type of y : number

Note - typeof  एक reserve keyword है जिसका use variable type जानने के लिए किया जाता है।

JS Bigint

bigint अभी जल्दी में JavaScript में add किया गया था  , bigint type की value define करने के लिए number के end में 'n' append करते हैं।

Another File : js_bigint.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Data Type : Bigint</title>
  </head>
  <body>
    <script>
      let x = 10n;
      document.write('type of x : '+ typeof x);
    </script>
  </body>
</html>
Output
type of x : bigint

JS String

JavaScript में तीन तरह से string type के variables define कर सकते हैं -

  • Single Quoted String - 'string'
  • Double Quoted String - "string"
  • Backticks - `string`

Note - Backticks (``) का use करके define की गयी string में हम ${ } ( dollar curly braces) के अंदर हम direct variables को print करा सकते हैं।

For Example :

document.write(`Print variable : ${var}`);

इसके अलावा JavaScript में हम new keyword के साथ भी string बना सकते हैं। जिसका type Object होता है।

Another File : js_string.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Data Type : String</title>
  </head>
  <body>
    <script>
      let x = 'string';
      let y = "string";
      let z = `string`;
      document.write('type of x : '+ typeof x);
      document.write('<br>type of y : '+ typeof y);
      document.write('<br>type of z : '+ typeof z);
      /*now try with new keyword */
      let s = new String("MyString");
      document.write('<br>type of z : '+ typeof s);
    </script>
  </body>
</html>
Output
type of x : string
type of y : string
type of z : string
type of s : object

Note - Example में '<br>' का use line break के लिए किया गया है ।

JS Boolean

Boolean Type दो values हैं true और false हालाँकि Boolean value किसी expression से भी आ सकती है जैसे conditional operator या logical operator के through .

Another File : js_boolean.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Data Type : Boolean</title>
  </head>
  <body>
    <script>
      let x = true;
      let y = false;
      document.write('type of x : '+ typeof x);
      document.write('<br>type of y : '+ typeof y);
      document.write('<br>Expression : '+ typeof (5>9));
    </script>
  </body>
</html>
Output
type of x : boolean
type of y : boolean
Expression : boolean

JS null

null special  type value है जो कि empty string या empty represent करती है। इसे किसी variable में null assign करके define किया जा सकता है।


हालाँकि अगर आप इसका data type check करोगे तो ये Object type का है

Another File : js_null.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Data Type : null</title>
  </head>
  <body>
    <script>
      let x = null;
      document.write('type of x : '+ typeof x);
    </script>
  </body>
</html>
Output
type of x : object

JS undefined

undefined means जिसे define नहीं किया गया है , या वह variable जिसे कोई value assign नहीं की गयी हो।

Another File : js_undefined.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Data Type : undefined</title>
  </head>
  <body>
    <script>
      let x;
      document.write('type of x : '+ typeof x);
    </script>
  </body>
</html>
Output
type of x : undefined

JS object

object एक special data type है , अभी तक ऊपर हम जो भी data types पढ़ रहे थे वो सभी Primitives Data Type थे जिनमें हम सिर्फ single value store कर सकते थे। Object के बारे में हम आगे deeply पढ़ेंगे।

Another File : js_object.html

Copy Fullscreen Close Fullscreen Run
<!DOCTYPE html >
<html>
  <head>
    <meta charset="utf-8">
    <title>Js Data Type : object</title>
  </head>
  <body>
    <script>
      document.write('type of Math : '+ typeof Math);
    </script>
  </body>
</html>
Output
type of Math : object

Note - example में Math एक predefined JavaScript Object है जिसका use mathematical tasks perform करने के लिए किया जाता है।

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers