Txt

Byte sized tech know-how.

  • Home
  • About

Tag Archives: apply

28 Aug

Scope and Binding in JavaScript

Function x executions in the scope of object y.


var Car = function() { this.name = 'car'; }
var Truck = function() { this.name = 'truck'; }

var func = function() { alert(this.name); }

var c = new Car();
var t = new Truck();

func.apply(c);
func.apply(t);

Original Article
[tags]javascript,apply,call,binding[/tags]

admin Posted in Code, JavaScript apply, binding, call, JavaScript Leave a comment

Post navigation

Categories

  • Code
  • Command Line
  • Configuration
  • CSS
  • HTML
  • internet
  • JavaScript
  • Linux
  • Mobile
  • Perl
  • PHP
  • Python
  • Ruby
  • Uncategorized

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Fruitful theme by fruitfulcode Powered by: WordPress
↑