charCodeAt() মেথড দেওয়া ইনডেক্সের ক্যারেক্টারের ইউনিকোড ভ্যালু নির্দেশকারী একটি সংখ্যা রিটার্ন করে। ইউনিকোড কোড পয়েন্ট ০ থেকে ১,১১৪,১১১ পর্যন্ত। প্রথম ১২৮ ইউনিকোড কোড পয়েন্ট ASCII ক্যারেক্টার এনকোডিং-এর সরাসরি ম্যাচ।
charCodeAt(index) নিচের প্যারামিটার সাপোর্ট করে −
- index − ০ এবং স্ট্রিং দৈর্ঘ্যের চেয়ে ১ কম পর্যন্ত একটি ইন্টিজার; অনির্দিষ্ট থাকলে, ডিফল্ট ০।
উদাহরণ
নিচের কোডটি রান করে ক্যারেক্টারের ইউনিকোড ভ্যালু নির্দেশকারী সংখ্যা রিটার্ন করুন −
<html> <head> <title>JavaScript String charCodeAt() Method</title> </head> <body> <script> var str = new String( "This is string" ); document.write("str.charCodeAt(0) is:" + str.charCodeAt(0)); document.write("<br />str.charCodeAt(1) is:" + str.charCodeAt(1)); document.write("<br />str.charCodeAt(2) is:" + str.charCodeAt(2)); document.write("<br />str.charCodeAt(3) is:" + str.charCodeAt(3)); document.write("<br />str.charCodeAt(4) is:" + str.charCodeAt(4)); document.write("<br />str.charCodeAt(5) is:" + str.charCodeAt(5)); </script> </body> </html>