ব্রাউজারের স্টোরেজ অবজেক্টের ভিতরে থাকা আইটেমগুলির সংখ্যা পাওয়ার জন্য HTML DOM স্টোরেজ দৈর্ঘ্যের বৈশিষ্ট্য ব্যবহার করা হয়। স্টোরেজ অবজেক্ট একটি লোকাল স্টোরেজ অবজেক্ট বা সেশন স্টোরেজ অবজেক্ট হতে পারে।
সিনট্যাক্স
−
-এর সিনট্যাক্স নিচে দেওয়া হললোকাল স্টোরেজ অবজেক্ট -
ব্যবহার করে স্টোরেজ দৈর্ঘ্যের বৈশিষ্ট্যlocalStorage.length;
সেশনস্টোরেজ অবজেক্ট
ব্যবহার করে স্টোরেজ দৈর্ঘ্যের বৈশিষ্ট্যsessionStorage.length;
উদাহরণ
আসুন আমরা স্টোরেজ লেন্থ প্রোপার্টি -
এর উদাহরণ দেখি<!DOCTYPE html>
<html>
<body>
<h1 style="text-align:center">Storage length property example</h1>
<p>Get how many storage items are stored in the local storage object by clicking the below button</p>
<button onclick="itemNum()">GET NUMBER</button>
<p id="Sample"></p>
<script>
function itemNum() {
var num = localStorage.length;
document.getElementById("Sample").innerHTML = "Number of storage items are "+num;
}
</script>
</body>
</html> আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবে

GET NUMBER -
-এ ক্লিক করলে
