首页 > 代码库 > 链式编程

链式编程

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <title></title>    <script type ="text/javascript">        var per = new Object();        per.name = "张三";        per.age = 10;        per.growUp = function () {            this.age++;            return this;//链式编程的关键是方法返回当前的这个对象        }        per.sayHi = function () {            alert(this.name+"age="+this.age);        }        per.growUp().growUp().sayHi();    </script></head><body></body></html>