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

236
Visualizações
How to find the implementation code of a vanilla JavaScript function

A colleague and I were discussing the implementation of the JavaScript "if" statement and I wanted to find the implementation so we could read through it and hopefully get a bit wiser.

However, I wasn´t able to find it anywhere, so my question is; Where do you go to read the JavaScript source code?

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

0

if is not a function but is a keyword. There is no JavaScript implementation of it.

The compiler/transpiler understands the if statement just like it understands other tokens from the var, const, and let to do {} while(); and for. All of these are keywords with special meaning known to the JavaScript interpreter.

You would want to look the implementation of the interpreter/compiler and runtime implementation to understand how it handles the various control keywords such as if. Alternatively you can look at the specs of the language.

Edit:

It is worth noting that JavaScript is ECMAScript. There are ECMAScript standards and JavaScript implements these. So concepts such as truthiness and falsiness (whether a value is truthy of falsey) is in the ECMAScript standards.

Particularly, you can check section 13.6.7 that speaks to the semantics of the if statement: https://262.ecma-international.org/11.0/#sec-if-statement-runtime-semantics-evaluation

From there, one can find what it means for something to be truthy/falsey, which is ToBoolean, as defined in the specs (not a JavaScript function):

enter image description here

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