扫码关注官方订阅号
function obj(){ //怎么按顺序执行弹出a,b,c } var obj1=new obj() obj.a().b().c()
业精于勤,荒于嬉;行成于思,毁于随。
function obj() { this.a = function() { alert('a'); return this; }; this.b = function() { alert('b'); return this; }; this.c = function() { alert('c'); return this; }; } var obj1=new obj(); obj1.a().b().c(); // 依次弹出a、b、c
function obj() { this.a = function() { alert('a') return this } ...... }
写个不容易懂的版本吧,但请不要怀疑他的正确性。
function obj() { return { a:function(){ alert("a"); return {b: function () { alert("b"); return {c:function (){ alert("c"); }} }} }} } new obj().a().b().c()
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
写个不容易懂的版本吧,但请不要怀疑他的正确性。