Mitsubishi m80 system unlock password decryption

The promotion of Mitsubishi m80 system unlock password variables is determined by the variable scope, that is, the variables declared in the global scope will be promoted to the top level of the global, and the variables declared in the function will only be promoted to the top level of the function scope.
Entry level
Dilemma:
console.log (a);
var a = 0;
copy the code and this will not report: Uncaught ReferenceError: a is not defined.
Instead, it will output undefined.
Because the result after variable promotion is:
var a;
console.log (a);
a = 0;
copy the code into class
Example 1:
var x = 0;
function a () {
console.log (x);
let x = 1 ;
}
a ();
Copy the code If let x does not promote the variable, then x should output 0, in fact:
VM296: 3 Uncaught ReferenceError: Cannot access 'x' before initialization
at a (: 3: 14)
at: 1: 1
it is not an error x not defined, but Cannot access.
What is the reason for this error?
Example 2:
let a = a;
let a = a;
copy the code, what error do you think will be reported?
"A not defined" or "Cannot access 'a' before initialization"?
Actually not, but an error: a has already been declared.

Here it looks like: let will also "variable promotion", if it will not be promoted, x in example 1 should output 0, and example 2 should report an a not defined error.
But if the variables will be promoted, it will not be justified, then the above example 1 should output undefined.
So we call this "temporary dead zone".
In fact, this is neither a variable promotion nor a variable promotion that we understand. What is a temporary dead zone?
Let defines a variable with a "special declaration" process. When JS pre-parses, let the defined let and const "special declaration" be advanced in advance, similar to "raise hand". The JS engine specifies the same scope and the same variable Can only be "raised" once.
This is different from the definition and assignment of var. The declaration of var is that if it has already been declared, the latter directly ignores the declaration.
We continue to return to this topic.
let a = a; // define the variable a, I will temporarily identify as a1
let a = a; // define the variable a, I will temporarily identify as a2
Copy the code to pre-parse, declare a1, and then prepare to declare a2, this time, The JS engine found that when a2 was declared, a1 was already declared.
Therefore, it violates the rule of "the same scope, the same variable can only be declared once", and an error is reported directly. In fact, the a variable assigned in the code has not been read yet (the variable undefined error may be thrown when reading the variable).
Therefore, an error is reported, the error content: a2 has been declared (a is declared by a1).
So back to Example 1 above, when the code reads x, it finds that there is x declared by let, but it is not initialized, and then directly reports the error that x cannot be accessed.
So what is the magic of let variable "special declaration"?
In fact, it is the JS engine that introduces the declareData that was introduced when the let variable was promoted. During pre-resolution, it stores all the let and const declaration data in the scope.
In fact, the creation of all functions and variables in the scope needs to check whether they conflict with the value of declareData.
Example 3:
var a = 1; // define variable a, I temporarily labelled a1
let a = 2; // define variable a, I temporarily labelled a2,
copy code declareData declare variable a2, then prepare to define variable a1, and find declareData A2 has already been declared, and an error is reported directly: a1 has been declared because the variable a has been declared by a2.
Function promotion
Function promotion is similar to variable promotion, but it is slightly different.
Function expression
console.log (a); // undfined
var a = function () {}

console.log (a); // function a
function a () {}
Copy code function expression will not declare promotion, the first example output is undefined instead of not defined, because the variable promotion of the variable var a .
Block-level scope
console.log (a); // undefined
if (true) {
console.log (a); // function a
function a () {}
}
If the code is copied and promoted, there is no block-level effect Domain, but function promotion exists, this pre-analysis is as follows:
var a; // declaration of function a
console.log (a); // undefined
if (true) {
function a () {} // function a Define
console.log (a); // function a
}
Copy the code in fact function a () {} After pre-parsed, put the function declaration at the front of the function-level scope, and then promote the function definition to block-level effect The front of the domain.
Note: The function definition here is promoted to the forefront of block-level scope.
One more question:
try {
console.log (a); // undefined
aa.c;
} catch (e) {
var a = 1;
}
console.log (a); // 1
console.log (e); // Uncaught ReferenceError: e is not defined
Copy the code defined in the catch, a was declared earlier. But the e in the catch is not accessible from the outside.
If you think that catch is a "function scope", then the a inside should not be promoted to the outermost level. In fact, the block scope is followed in the catch.
In the JS field, there is block-level scope itself (outside of let const).
Look at the original question again.
In order to facilitate reading, I will post the subject again:
var a = 0;
if (true) {
a = 1;
function a () {}
a = 21;
console.log ("Inside", a);
}
console.log ("External", a);
Copy the code combined with the knowledge we learned above. First, the function a () {} in if will declare the promotion, move the declaration "var a" to the front of the function-level scope, and move the function definition to the front of the block-level scope. The pre-resolution is as follows:
var a; / / The declaration of function a
var a = 0; // The declaration of a has been declared, and the declaration will be ignored here, and the value will be directly assigned to 0
if (true) {
function a () {} // The declaration of function definition a will be promoted to the front
a = 1; // Here the function a at the front of the block scope is reset to 1.
// function a () {}; how do?
a = 21;
console.log ("inside", a);
}
console.log ("outside", a);
Copy code The function itself is [define function name variable pointer to function memory block].
Function promotion is at block level scope, but function name variables are function level scope. Therefore, when the block-level function definition (the original code function declaration position), the function name variable is synchronized to the function-level scope, in fact, only this time, the function definition can be accessed outside the block-level scope.
The pre-analysis is as follows:
var a = 0;
console.log (a, window.a); // output 0 and 0
if (true) {
console.log (a, window.a); // function promotion is block level Scope, output function a and 0
a = 1; // Take function a of the nearest block-level scope of scope, and it is reset to 1, which is essentially a variable assignment.
console.log (a, window.a); // a is a pointing to the scope of the block level, output 1 and 0
function a () {} // declaration of the function, synchronize the definition of the variable that executes the function to the function level Scope.
console.log (a, window.a); // output 1 and 1
a = 21; // still a of function-defined block scope, reset to 21
console.log (a, window.a); / / The output is a of the block-level scope of the function promotion, output 21, 1
console.log ("inside", a);
}
console.log ("outside", a);

Published 28 original articles · Likes0 · Visits 907

Guess you like

Origin blog.csdn.net/srhgsr/article/details/105499946