Pergunta de entrevista da empresa EPAM Systems

What will be the result? console.log(a); var a; and here? a; const a;

Respostas da entrevista

Sigiloso

29 de jul. de 2020

In general, I'm not sure about the answer, since I never do that, since the IDE will always highlight the error and I will fix it. But I think in the first case "undefined" and in the second case "error".

Sigiloso

28 de set. de 2022

1. What will be the result? console.log(a); var a; Answer: you will get an error as you are trying to console a property before declaring it . 2. a; const a; Answer: here if you are declaring this "a" property in a component you will get error you are not defining type or initial value to it. second for "const a" you will also receive an error as, while declaring const you should pass a initial value to it. which can not be changed after that.