कोड स्ट्रिंग से जावास्क्रिप्ट स्ट्रिंग () विधि कोड बिंदुओं के दिए गए अनुक्रम का उपयोग करके बनाई गई एक स्ट्रिंग लौटाती है।
fromCodePoint()
विधि का सिंटैक्स है:
String.fromCodePoint(num1,… , numN)
fromCodePoint()
विधि, एक स्थिर विधि जा रहा है, का उपयोग करते हुए कहा जाता है String
वर्ग के नाम।
fromCodePoint () पैरामीटर्स
fromCodePoint()
विधि में लेता है:
- num1,…, numN - कोड पॉइंट्स का एक क्रम।
CodePoint से वापसी मूल्य ()
- कोड बिंदुओं के निर्दिष्ट अनुक्रम का उपयोग करके बनाई गई एक स्ट्रिंग लौटाता है।
नोट :
fromCodePoint()
विधि एक फेंकताRangeError
है, तो गलत यूनिकोड कोड बिंदु दिया जाता है।fromCodePoint()
विधि एक स्ट्रिंग, न कि रिटर्नString
वस्तु।
उदाहरण: का प्रयोग कर रहा है। कोड () विधि से
let string1 = String.fromCodePoint(65, 66, 67); console.log(string1); // ABC let string2 = String.fromCharCode(72, 69, 76, 76, 79); console.log(string2); // HELLO // numbers can be passed as hexadecimals let string3 = String.fromCodePoint(0x2f804); console.log(string3); // "uD87EuDC04" // unlike fromCharCode() that requires surrogate pair to return supplementary char // fromCodePoint() can even return 4-byte supplementary chars let string4 = String.fromCodePoint(0x1f303); console.log(string4); // Unicode character "Night with Stars" let string5 = String.fromCodePoint(Infinity); console.log(string5); // RangeError
आउटपुट
एबीसी हेलो uD87E uDC04 रेंजError: अमान्य कोड बिंदु इन्फिनिटी
अनुशंसित रीडिंग: जावास्क्रिप्ट स्ट्रिंग स्ट्रिंग सेकोड ()