Tuesday, December 13, 2022

PrepareForOrdinaryCall

PrepareForOrdinaryCall( F, newTarget )

PrepareForOrdinaryCall( F, newTarget ) where F is a function object and newTarget is Undefined or Object:

  1. let calleeContext be a new code execution context as:
  2. Push calleeContext onto the execution context stack; suspending the old while making calleeContext the running context
  3. return calleeContext

Monday, December 12, 2022

SameValue, SameValueZero and Strict Equality Comparison

SameValue, SameValueZero and Strict Equality Comparison

SameValue differs from the Strict Equality Comparison Algorithm in its treatment of signed zeroes and NaNs: +0 === -0 and !(NaN === NaN)

SameValueZero differs from SameValue only in its treatment of +0 and -0.

NewGlobalEnvironment

NewGlobalEnvironment ( G, thisValue )

NewGlobalEnvironment ( G, thisValue ) returns a new global env who's outer lexical environment is null and its global Environment Record created as globalRec:

  1. .[[ObjectRecord]]: a new object Environment Record who's binding object is G
  2. .[[DeclarativeRecord]]: a new declarative Environment Record; [[VarNames]]: a new empty List.
  3. .[[GlobalThisValue]]: thisValue (zxxu: thisValue and G means different stuff? according to SetRealmGlobalObject and InitializeHostDefinedRealm, they can be the same but also can be different)

NewFunctionEnvironment

NewFunctionEnvironment ( F, newTarget )

NewFunctionEnvironment ( F, newTarget ):

  1. Assert: Type(newTarget) is Undefined or Object.
  2. Let envRec be a new function Environment Record containing no bindings.
  3. Set envRec.[[FunctionObject]] to F.
  4. If F.[[ThisMode]] is lexical, set envRec.[[ThisBindingStatus]] to lexical.
  5. Else, set envRec.[[ThisBindingStatus]] to uninitialized.
  6. Set envRec.[[HomeObject]] to F.[[HomeObject]].
  7. Set envRec.[[NewTarget]] to newTarget.
  8. Return a new Lexical Environment who's EnvironmentRecord is envRec and outer lexical environment is F.[[Environment]].

Sunday, December 11, 2022

Consent letter for children travelling outside Canada

Countries have their own entry and exit requirements for children. The consent letter may not be considered sufficient by a country’s immigration authorities and there is no guarantee that they will recognize it. For more information, check the entry and exit requirements in the Travel Advice and Advisories for your destination country or contact the nearest embassy or consulate of the destination country before travelling. For example, to check for requirements for America , can send a letter to armcanadaembassy@mfa.am such as:


hi, armembassycanada.ca:

If my child will travel to America without myself, is there a consent form to submit ONLINE indicating her/his temp guardian as my friend when she/he is in America?

thanks

A sample Consent letter can be found at https://travel.gc.ca/travelling/children/consent-letter

Function Environment Record

Function Environment Record

GetSuperBase():

  • Let envRec be the function Environment Record for which the method was invoked.
  • Let home be envRec.[[HomeObject]].
  • If home has the value undefined, return undefined.
  • Return home.[[Prototype]].
  • would it better to rename it into GetSuper or GetSuperObject()?

GetThisBinding():

  • Assert: envRec.[[ThisBindingStatus]] is not lexical.
  • If envRec.[[ThisBindingStatus]] is uninitialized, throw a ReferenceError exception.
  • Return envRec.[[ThisValue]].

HasSuperBinding():

  • If envRec.[[ThisBindingStatus]] is lexical, return false.
  • If envRec.[[HomeObject]] has the value undefined, return false; otherwise, return true.
  • zxxu:[[HomeObject]] is meanful only when has super accesses; ecma: [[HomeObject]] is the object that the function is bound to as a method; zxxu: [[HomeObject]] is added since es6 to support class definitions

HasThisBinding(): If envRec.[[ThisBindingStatus]] is lexical, return false; otherwise, return true.

BindThisValue(V):

  • Assert: envRec.[[ThisBindingStatus]] is not lexical.
  • If envRec.[[ThisBindingStatus]] is initialized, throw a ReferenceError exception.
  • Set envRec.[[ThisValue]] to V.
  • Set envRec.[[ThisBindingStatus]] to initialized.
  • Return V.

Saturday, December 10, 2022

the this keyword of JS

the this keyword of JS
class Polygon {
  constructor() {
    this.name = 'Polygon';
  }
}

const poly1 = new Polygon();

console.log(poly1.name); //Polygon


function outer_func()
{
    function inner_func()
    {
        this.prop01 = "value of prop01";
    }
    inner_func();
}

outer_func()

console.log( "prop01=" + prop01 )//value of prop01

var prop02 = "value of prop02";
console.log( "prop02=" + this.prop02 )//value of prop02

outer_func.inner_func2 = function (){
    this.prop03 = "value of prop03";
}
outer_func.inner_func2();
console.log( "prop03=" + outer_func.prop03 )//value of prop03