SóProvas


ID
315733
Banca
FCC
Órgão
TRE-RN
Ano
2011
Provas
Disciplina
Programação
Assuntos

Usado no âmbito do objeto String do JavaScript. Concatena caracteres representados por códigos Unicode, em uma nova string. Trata-se de

Alternativas
Comentários
  • Veja: http://www.mspc.eng.br/info/jscriptString.shtml
  • Interessante que na documentação no link postado ele fala apenas em ASCII.
  • fromCharCode

    Definition and Usage

    The fromCharCode() method converts Unicode values to characters.

    Note: This method is a static method of the String object. The syntax is always String.fromCharCode() and not string.fromCharCode().

    Syntax

    String.fromCharCode(n1, n2, ..., nX)

    Parameter Description
    n1, n2, ..., nX Required. One or more Unicode values to be converted

    fonte: http://www.mspc.eng.br/info/jscriptString.shtml
  • <!DOCTYPE html>
    <html>
    <body>
     
    <p id="demo">Click the button to display characters of the specified unicode numbers.</p>
     
    <button onclick="myFunction()">Try it</button>
     
    <script>
    function myFunction()
    {
    var n=String.fromCharCode(72,69,76,76,79);
    document.getElementById("demo").innerHTML=n;
    }
    </script>
     
    </body>
  • Questao mal feita. O comando converte o código para o caractere. Nao tem nada a ver com concatenar.

  • I) Convert a Unicode number into a character:
    var res = String.fromCharCode(65) = A;

     

    II) Join two strings:
    var str1 = "Hello ";
    var str2 = "world!";
    var res = str1.concat(str2) = “Hello World”

     

    III) Return the Unicode of the first character in a string (the Unicode value for "H"):
    var str = "HELLO WORLD";
    var n = str.charCodeAt(0) = 72;

     

    IV) Search a string for "ain":
    var str = "The rain in SPAIN stays mainly in the plain";
    var res = str.match(/ain/g) = "ain,ain,ain";


    V) Return the first character of a string:
    var str = "HELLO WORLD";
    var res = str.charAt(0) = "H";

  • Que questão mal feita! "fromCharCode" converte um número Unicode para um caracter. O que tem haver?????