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

160
Visualizações
Different results came from different editor in terms of .this keyword

Everyone. I am learning javascript. I ran this code: (below)

function x(){
  return this;
}

console.log(x() === global);

in Atom editor, then got a result which was "false". (please see my added picture) However, I turned to another online editor to run the same code then got the result "true" ! (please see my added picture)

My question one is : Is it Atom's problem leading to different results ?

My question one two : I heard that "===" is named strict equality, which means it will be "false" if left operand is different with right operand. But, in the code I just have posted, in this line "(x() === global)", the result is "true" while the left operand and the right operand are certainly different, so what is wrong with it, is it that I am still not learning about some fundamental concepts?

Waiting for your answer Hopefully! enter image description here

enter image description here

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

0

in "sloppy mode" this keyword in a function refers to the global object. while in strict mode its value is undefined. I'm not sure about your editor's settings but I would say both are correct depending on the settings. It could be that atom sets strict mode by default while the other editor doesn't.

More on what is strict mode and what does it effect and why it is used for in MDN documentation

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