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

106
Visualizações
Why is toString always running in strict mode?

I know that according to ECMAScript specification, non-strict methods will have thisArg transformed to the global object, if null or undefined was passed to them. That's the reason this code logs the window object (in browsers) instead of null:

function x() {
    console.log(this);
}
x.call(null);

What I don't understand, is why doing the same thing with Object.prototype.toString.call(null), doesn't transform null to the global object, but keeps it as null and returns the string [object Null].

Is it because 'use strict' is used in default implementation of toString method? Is every built-in method run in strict-mode?

I couldn't find anything like that in the specification a https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.prototype.tostring.

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

0

Is every built-in method run in strict-mode?

Yes. It says so in §10.3 Built-in Function Objects:

"Built-in functions that are ECMAScript function objects must be strict functions."

This not only implies non-sloppy handling of the this argument, but also that these functions have no .arguments, .callee and .caller properties.

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