In fact, the letters of the Arabic alphabet are these
var RTL = ['ا','ء','ب','ت','ث','ج','ح','خ','د','ذ','ر','ز','س','ش','ص','ض','ط','ظ','ع','غ','ف','ق','ک','ل','م','ن','و','ه','ی'];
and Persian (Farsi) letters of the alphabet - these
var RTL = ['ا','ب','پ','ت','ث','ج','چ','ح','خ','د','ذ','ر','ز','ژ','س','ش','ص','ض','ط','ظ','ع','غ','ف','ق','ک','گ','ل','م','ن','و','ه','ی'];
and it can be useful if you check the first and second letter, because sometimes it can start with a bullet or something like that.
for ( var index = 0; index < divs.length; index++ ) { if( checkRtl( divs[index].textContent[0] ) || checkRtl( divs[index].textContent[1] ) ) { divs[index].className = 'rtl'; } else { divs[index].className = 'ltr'; }; };