Terminal printando in yellow

Asked

Viewed 38 times

3

Hello, I am learning Javascript and in my terminal, when I run some code, some prints come out in yellow. Does anyone know why ? Thanks.

const peso1 = 1.0
const peso2 = Number('2.0')
const peso3 = 1.1
console.log(peso1, peso2)  
console.log(Number.isInteger(peso1))
console.log(Number.isInteger(peso2))
console.log(Number.isInteger(peso3))
const avaliacao1 = 9.871
const avaliacao2 = 6.871
const total = avaliacao1 * peso1 + avaliacao2 * peso2
const media = total/ (peso1+peso2)
console.log(media)
console.log (media.toFixed(2))
console.log(media.toString())
console.log(media.toString(2))
console.log(typeof media)

inserir a descrição da imagem aqui

1 answer

4

The colors are to differentiate strings from other types (such as boolean and numbers). In the CMD of your print the strings appear blank.

In browsers there is also color differentiation. In the prints below, I changed the line const peso1 = 1.0 for const peso1 = "1.0" (1.0 as a string, just to illustrate):

Chrome

inserir a descrição da imagem aqui

Firefox

inserir a descrição da imagem aqui

In Edge there is no distinction of types (and colors). That’s why he grouped the 3 values 23.15:

inserir a descrição da imagem aqui

  • It would be nice to link to something that confirms this (ok, the test already confirms, but if you give a link to official documentation or something like that, always value)

  • Yes @Bacco, that would be great. I’m doing a broad search to see if I find any good reference to insert in the answer (but it’s hard to find).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.