Code Monkey home page Code Monkey logo

Comments (3)

cobish avatar cobish commented on September 12, 2024

08 月 16 日

JS

执行上下文栈

  • 举个例子,当执行到一个函数时,就会进行准备工作,这里的“准备工作”,更专业一点来说,就是“执行上下文(execution context)”。
  • JavaScript 引擎会创建一个执行上下文栈(Execution context stack),用来管理执行上下文。
  • 当执行一个函数的时候,就会创建一个执行上下文,并且压入执行上下文栈。当函数执行完毕的时候,就会将函数的执行上下文从栈中弹出。

from demo.

cobish avatar cobish commented on September 12, 2024

08 月 17 日

JS

变量对象

  • 变量对象存储了再上下文中定义的变量和函数声明。
  • 全局上下文中的变量对象就是全局对象。
  • 在函数上下文中,用活动对象(activation object, AO)来表示变量对象。
执行过程
  1. 进入执行上下文
  2. 代码执行
进入执行上下文

进入执行上下文时,代码还没被执行。

变量对象会包括:

  1. 函数的所有形参。
  2. 函数声明。
  3. 变量声明。
代码执行

代码执行阶段,会再次修改变量对象的属性值。

from demo.

cobish avatar cobish commented on September 12, 2024

08 月 21 日

JS

Array.prototype.slice.call(arguments)

Array.prototype.slice = function(start, end) {
  var result = new Array();
  start = start || 0;
  end = end || this.length;

  for (var i = start; i < end; i++) {
    result.push(this[i]);
  }

  return result;
};

instanceof

instanceof 运算符用来测试一个对象在其原型链中是否存在一个构造函数的 prototype 属性。

from demo.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.