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

267
Visualizações
Suitescript adds .0 to numbers in array

In Suitescript 2.0 I want to check if an ID does not match with one of the IDs in the array below:

var interfaceStatusArray1 = [14, 15, 17, 20, 25, 26];

In the debugger I see that .0 is added to every value in the array :

enter image description here

Now if my ID is 1 and I do the following check:

 interfaceStatusArray1.indexOf(lineItemFieldValues.interfaceStatusID) == -1

then this will always be true, because the numbers have .0 added.

Is there a way to remove the .0? I already tried Math.trunc, but Netsuite gives me this error:

TypeError: Cannot find function trunc in object [object Math].

I also reproduced the code in jsfiddle however in jsfiddle it works, because it gets into false: https://jsfiddle.net/7fnxoz1r/1/

I am quite new to Suitescript 2.0 but it also seems that suitescript 2.0 does not allow array.includes.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Why not set interfaceStatusArray1 as a string array? If needed you can turn them to number back/forward using the primitive classes String(val)/Number(val)

about 4 years ago · Juan Pablo Isaza Relatório

0

This is not unique to NetSuite but is how JavaScript handles numbers: there are only numbers, not integers and floating point, so all numbers in JS are basically floating point. If you need to consume these as a number, the fact the ".0" is displayed won't matter. Indeed, if you ToString() them, the ".0" won't be in the string.

To use your example:

interfaceStatusArray1.indexOf(lineItemFieldValues.interfaceStatusID) == -1

If lineItemFieldValues.interfaceStatusID is 1.0, JavaScript would say the condition is false (1.0 !== -1.0). If you want to be sure, use "===" instead of "==" and add the ".0" in your condition.

about 4 years ago · Juan Pablo Isaza 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