Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
How is JavaScript string a set of elements of integer values?

From the MDN

JavaScript's String type is used to represent textual data. It is a set of "elements" of 16-bit unsigned integer values. Each element in the String occupies a position in the String. The first element is at index 0, the next at index 1, and so on. The length of a String is the number of elements in it. You can create strings using string literals or string objects.

What does it mean when you say the JavaScript String type is a set of "elements" of 16-bit unsigned integer values? Why integer values?

almost 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

The 16-bit unsigned integer values is a representation of specific characters and since it is a set of elements, you are able to grab specific characters within a string with [] notation as you would a list. Ex:

const string = 'john doe';
console.log(string[3]) // Will print 'n' as it is the 3rd index characters (starts at 0)
almost 4 years ago · Santiago Trujillo Relatório

0

it just means that a string is an "array-like" object with each character available in a similar manner to an array element. Each of those characters are stored as a UTF-16 value.

// The following is one string literal:
let s = "ABCDEFG";

console.log(s);

// But it's also an array-like object in that it has a length and can be indexed
console.log("The length of the string is: ", s.length);
console.log("The 3rd character is: ", s[2]);

// And we can see that the characters are stored as separate UTF-16 values:
console.log(s.charCodeAt(2));

almost 4 years ago · Santiago Trujillo Relatório

0

As I understood:

  1. unsigned means not + or -.
  2. 16 bit means 2^16 number of elements/characters can represent.
  3. set of Integers mean to represent a String use multiple integers (1 or more).

Therefore this means to represents a string js use set of numbers (each numbers is a 1 of 2^16 numbers because no float numbers and no positive/negative representation).

Note: to understand more read about utf-16

Reference:https://www.ibm.com/docs/en/i/7.2?topic=unicode-utf-16

almost 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda