Chaining JavaScript methods

Prabhukiran345
Posted by Prabhukiran345 under JavaScript category on | Points: 40 | Views : 518
JavaScript allows us to invoke multiple methods on an object in a single expression. This is called chaining and is accomplished by stringing the method calls together with dots between them,

NOTATION:
object.method1().method2().method3();

EXAMPLE

 1) account.number("012477630").setBalance(10971).applyCredit(200);

[IN SIMPLE MANNER]

2) $("#myDiv").removeClass("off").addClass("on").css("background": "red");

Comments or Responses

Login to post response