函数由四部分组成

function+function name+parameter+body

方法调用模式

  Object.add();

函数调用模式:

  add(3,4)

构造器调用模式:JS是基于原型继承的语言,对象可以直接从其它对象继承属性。因此提供一套和基于类的语言类似的对象构建语法

  var Quo=function(string){}; var MyQuo=new Quo("new"); // 创建一个prototype的新对象并复制给MyQuo, 默认为构造函数,不推荐使用。

AppLy调用模式:JS函数可以拥有方法,apply方法可以传递一个参数数据给调用参数。

  var statusObject={ status: 'A-OK' };

  var status=Quo.prototype.get_status.apply(statusObject); //这种写法等于MyQuo.get_status(statusObject);

函数中的参数:Js没有重载函数, 免费配送一个参数数据arguments[]

函数的扩展:通过增加以下语句可以增加一个全局函数。

   Function.prototype.method=function(name, func)

   {

    this.prototype[name]=func;

    return this;

   }

改进:当确定没有此函数时才加入方法。

Function.prototype.method=function(name, func)

   {

    if(!this.prototype[name])

      this.prototype[name]=func;

    return this;

   }

JS的函数的更多相关文章

  1. JS回调函数全解析教程

    转自:http://blog.csdn.net/lulei9876/article/details/8494337 自学jQuery的时候,看到一英文词(Callback),顿时背部隐隐冒冷汗.迅速g ...

  2. 学习js回调函数

    <!DOCTYPE HTML> <html> <head> <meta charset="GBK" /> <title> ...

  3. 如何理解JS回调函数

    1.回调函数英文解释: A callback is a function that is passed as an argument to another function and is execut ...

  4. Atitit java方法引用(Method References) 与c#委托与脚本语言js的函数指针

    Atitit java方法引用(Method References) 与c#委托与脚本语言js的函数指针   1.1. java方法引用(Method References) 与c#委托与脚本语言js ...

  5. 【转】关于URL编码/javascript/js url 编码/url的三个js编码函数

    来源:http://www.cnblogs.com/huzi007/p/4174519.html 关于URL编码/javascript/js url 编码/url的三个js编码函数escape(),e ...

  6. js引出函数概念的案例

    js引出函数概念的案例   1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8&q ...

  7. prototype.js $F()函数介绍

    $F()是一个能够简化编码量的函数, 对于字段输入控件有效,包括input.textarea.select等,该函数的输入参数为这些输入控件元素对象的id或元素对象本身,函数负责返回 这些输入控件元素 ...

  8. JS匿名函数的理解

    js匿名函数的代码如下:(function(){ // 这里忽略jQuery 所有实现 })(); 半年前初次接触jQuery 的时候,我也像其他人一样很兴奋地想看看源码是什么样的.然而,在看到源码的 ...

  9. js回调函数(callback)理解

    Mark! js学习 不喜欢js,但是喜欢jquery,不解释. 自学jquery的时候,看到一英文词(Callback),顿时背部隐隐冒冷汗.迅速google之,发现原来中文翻译成回调.也就是回调函 ...

  10. JS回调函数(callback)

    在使用Jquery的时候,用到Callback(),回调函数的概念.而且很多. 比如: $.ajax({ url:"test.json", type: "GET" ...

随机推荐

  1. public, protected and private inheritance in C++

    Get from Stackoverflow. The details can easily understand from the below example. class A { public: ...

  2. assert的用法

    assert用来调试时,判断一个语句是否为真. assert是宏,而不是函数.在C的assert.h 头文件中. assert的作用是先计算表达式 expression ,如果其值为假(即为0),那么 ...

  3. Linux 之HTTP服务,APACHE

    1.基础知识 HTTP:超文本传输协议,超链接URI:Uniform Resource Identifier,全局范围内唯一命名符MIME:Multipurpose Internet Mail Ext ...

  4. int数组转string数组和int数组转string中间用逗号隔开

    //int 数组转string数组 ,,,}; string result=test.Select(i => i.ToString()).ToArray(); //int 数组转 string中 ...

  5. Ogre 1.9 Android移植

    Ogre 1.9 Android移植 分类: 图形渲染2013-02-04 16:47 3860人阅读 评论(14) 收藏 举报 Android Ogre C++linuxLinuxLINUX 上一篇 ...

  6. C语言深度挖掘

    二级指针和回调函数的用法: #include <stdio.h> #include <stdlib.h> int add(int num1 ,int num2){ return ...

  7. asp.net Ajax和web services

    新建一个web服务 using System; using System.Collections.Generic; using System.Linq; using System.Web; using ...

  8. c语言中三个点的解释 : variadic

    3.6 Variadic Macros A macro can be declared to accept a variable number of arguments much as a funct ...

  9. Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute'

    [TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from as ...

  10. Redis(三)节省内部空间优化

    总体原则:key的名称不易过长,剩下的所有 能用纯数字表示的尽量用 Redis的每一个键值都是用一个redisObject结构体表示的结构体中有:    键值的类型(string/list/hash/ ...