المسارات / JavaScript / المرجع / String.fromCharCode

مرجع · String

String.fromCharCode

String.fromCharCode بتبني نص من أكواد الـcode units، ومش بتشتغل صح مع الأكواد فوق 65535 زي الإيموجي.

What does String.fromCharCode() do in JavaScript?

js
String.fromCharCode(...codes)

دي عكس charCodeAt. مع الأكواد فوق 65535 بتحتاج fromCodePoint، وإلا النتيجة بتطلع حرف غلط.

البرهان

شُغّل على Node v26.14.0، والناتج منسوخ من التشغيل نفسه.

js
console.log(String.fromCharCode(65, 66), String.fromCodePoint(128512));
console.log(String.fromCharCode(128512), String.fromCodePoint(65, 66));
النتيجة
AB 😀
 AB

الدروس اللي بتشرحها

الصفحة دي على MDN ↗

ابعت الصفحة لحد
واتسابتليجرامX
برهان

الدروس

اتحلّ 0 من 174 تمرين