javascript vérifier si une chaine de carctère commence par une majuscule code example

Example: javascript vérifier si une chaine de carctère commence par une majuscule

/* Test if a character is uppercase by converting it to lowercase 
 *   and comparing that with the original. 
 * If they are different, the original was uppercase. 
 * If they are the same, the original was either a lowercase character
 *   or a character that doesn't have uppercase and lowercase 
 *   versions (e.g. a number or punctuation mark).
*/
function isUpperCase(char)
{
  // 'char' is a string containing a single character
  return char !== char.toLowerCase();
}

Tags:

Misc Example