If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
JavaScript dynamic type language language है means किसी variable को initialize करते समय हमें इसमें assign की गयी value के type को declare नहीं करना पड़ता है , जिस भी तरह की हम value assign करते है JavaScript Engine इसे automatically convert कर देता है।
JavaScript में use होने वाले data types इस प्रकार हैं -
JavaScript में integer या floating points दोनों तरह के लिए same data type number ही है
Another File : js_number.html
<!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>
Note - typeof एक reserve keyword है जिसका use variable type जानने के लिए किया जाता है।
bigint अभी जल्दी में JavaScript में add किया गया था , bigint type की value define करने के लिए number के end में 'n' append करते हैं।
Another File : js_bigint.html
<!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>
JavaScript में तीन तरह से string type के variables define कर सकते हैं -
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
<!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>
Note - Example में '<br>' का use line break के लिए किया गया है ।
Boolean Type दो values हैं true और false हालाँकि Boolean value किसी expression से भी आ सकती है जैसे conditional operator या logical operator के through .
Another File : js_boolean.html
<!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>
null special type value है जो कि empty string या empty represent करती है। इसे किसी variable में null assign करके define किया जा सकता है।
हालाँकि अगर आप इसका data type check करोगे तो ये Object type का है
Another File : js_null.html
<!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>
undefined means जिसे define नहीं किया गया है , या वह variable जिसे कोई value assign नहीं की गयी हो।
Another File : js_undefined.html
<!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>
object एक special data type है , अभी तक ऊपर हम जो भी data types पढ़ रहे थे वो सभी Primitives Data Type थे जिनमें हम सिर्फ single value store कर सकते थे। Object के बारे में हम आगे deeply पढ़ेंगे।
Another File : js_object.html
<!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>
Note - example में Math एक predefined JavaScript Object है जिसका use mathematical tasks perform करने के लिए किया जाता है।
Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook