4
I know that variable statements are all high for the whole of the scope, but I was left with a little doubt about this, the use of the word 'use Strict' avoids q declare variables like this
a = 10
But why in this situation below it allows to show the value of this in the function even if with the word 'use Strict'.
function foo(){
console.log(this);
}
"use strict";
function minhaFuncao() {
console.log(this); //Deveria ter mostrado undefined
}
myFunction();
foo();
The elevation occurred and would have been like this ?
function foo(){
console.log(this);
}
function minhaFuncao(){
console.log(this);
}
'use Strict';
Is it right what I’m thinking ? , or something else happened, thanks in advance
I understood then in case it depends on the context in which this is employed, but the use of use Strict would not avoid iso ? or I’m wrong ?
– teste-90
Dear @Diogosouza he explained, this is not variable, and another thing use Strict does not change an "integer behavior", only changes the behavior for "strict" things, as avoid objects with duplicate keys, avoid set "undefined" variables and things like that. This will continue to be a "context"
– Guilherme Nascimento
@You can limit the value of
this
, I gathered more information in reply, I was just in a hurry. The use ofuse strict
does not avoid the use ofthis
but, yes, limits it if the execution context is global.– Sergio
Okay, thank you very much
– teste-90