js
string.charAt(index)الأماكن بتبدأ من 0. الفرق عن str[index]: charAt بترجّع '' لما المكان مش موجود، بينما str[index] بترجّع undefined. مع الحروف المركّبة (emoji) charAt بياخد جزء من الحرف، فالأفضل [...str] للحروف دي.
البرهان
js
const s = 'أهلا';
console.log(s.charAt(0), s.charAt(10) === '');
console.log('abc'.charAt(1));
console.log('abc'[10] === undefined);
console.log([...'👋🏽'].length, '👋🏽'.length);النتيجة
أ true b true 2 4