GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing fa.javascript.info — متد bind دوم

  • آموزش
  • زبان جاوااسکریپت
  • استفاده پیشرفته از تابع‌ها
  • پیوند تابع
بازگشت به درس

متد bind دوم

اهمیت: 5

آیا می‌توانیم با پیوند زدن اضافی this را تغییر دهیم؟

خروجی چه خواهد بود؟

function f() {
  alert(this.name);
}

f = f.bind( {name: "John"} ).bind( {name: "Ann" } );

f();

جواب: John.

function f() {
  alert(this.name);
}

f = f.bind( {name: "John"} ).bind( {name: "Pete"} );

f(); // John

شیء بیگانه تابع پیوند زده شده که توسط f.bind(...) برگردانده شده، زمینه (و در صورت قرار دادن، آرگومان‌ها) را فقط در زمان ایجاد شدن به یاد می‌سپارد.

یک تابع نمی‌تواند دوباره پیوند زده شود.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.