201510222231_《JavaScript——函数——4种方式调用》

1.方法调用模式; 形如: var dog = { name: "aWang", speak: function(){ //to do } }; dog.speak(); ------------------------------------------------------------------ 2.函数调用模式; 形如: var speak = function(){ //to do }; speak(); ------------------------------------------------------------------ 3.构造器调用模式; 形如: var speak = function(){ //to do }; var obj = new speak(); obj.speak(); ------------------------------------------------------------------ 4.apply调用模式; 形如: var sum = function(a ,b){ return a + b; }; sum.apply(this,[a,b]);
posted @ 2015-10-22 22:44  Coca-code  阅读(127)  评论(0编辑  收藏  举报