Named Function Expression

380 ワード

var c = function c() {
    c = "AB";
    console.log(c);
    console.log(c === arguments.callee)
};
c();

上記のコードは典型的なNamed Function Expressionであり、通常の匿名メソッドとは異なり、メソッド内でcはargumentsとして機能する.calleeなので読み取り専用で修正できません.
この例ではcはメソッド内で修正できず,最後の結果は
ƒ () {
    console.log(c);
    console.log(c === arguments.callee)
}

 

true