- 浏览: 3292352 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (567)
- Web前端-html/表单 (19)
- Web前端-CSS (24)
- Web前端-CSS框架 (4)
- Web前端-JS语言核心 (50)
- Web前端-JS客户端 (26)
- nodejs生态+grunt (10)
- seajs和requirejs (9)
- backbone等框架 (7)
- 模板基础 (7)
- Web前端-deps(不改动) (6)
- Web前端-component (10)
- Web前端-jquery-plugin (13)
- 浏览器兼容性 (6)
- Web前端-使用jQuery (25)
- Web前端-使用jqueryui (6)
- Web前端-性能优化 (3)
- Web协议-HTTP (6)
- ExtJS (13)
- PHP (22)
- PHP面向对象 (4)
- PHP扩展-SOAP (6)
- PHP扩展-curl (4)
- PHP与HTML(导出) (5)
- PHP扩展-综合 (7)
- mysql基础应用 (18)
- 技术心情 (18)
- 算法和面试题 (17)
- 工具(开发)使用 (36)
- memcached原理 (2)
- session和cookie (4)
- UML (2)
- Web前端_FusionCharts (5)
- Web前端_Flex (4)
- Web前端_JSP (3)
- JavaSE (10)
- JavaEE (4)
- tomcat (2)
- Servlet开发 (3)
- Spring开发 (1)
- REST相关 (2)
- 大访问量、高并发 (2)
- 网络编程 (1)
- YII (21)
- linux命令和内核 (12)
- yii与数据库 (10)
- yii与表单 (12)
- yii view层 (1)
- perl (7)
- yii扩展 (7)
- shell (4)
- photoshop (7)
- 视觉设计 (2)
- 我关注的名人在路上 (4)
- 1-自学能力 (1)
- 2-人际沟通能力 (3)
- 3-职业规划能力 (7)
- 4-项目管理能力 (2)
- python (3)
- django (4)
- Mysql高级应用 (6)
- prototype.js (4)
- Web系统安全 (1)
- Web前端-mobile (2)
- egret (6)
- jQuery源码分析 (5)
- fis (4)
最新评论
-
yzq21056563:
感谢作者分享~请教下,http://www.lisa33xia ...
CSS基础:text-overflow:ellipsis溢出文本 -
u012206458:
$.ajax的error,complete,success方法 -
DEMONU:
谢谢,虽然不能给你赞助,但是要给你顶
mysql中key 、primary key 、unique key 与index区别 -
njupt_tolmes:
阿凡达阿凡达阿凡达阿凡达阿凡达阿凡达阿凡达阿凡达阿凡达阿滕庆亚 ...
CSS基础:text-overflow:ellipsis溢出文本 -
zenmshuo:
用过SpreadJS,也包含数据可视化的图表
推荐几个web中常用js图表插件
作者:zccst
2014-6-10 自己构造一个Array like
类数组的构成要点:
1,元素是数组式索引
2,有length属性
2014-6-9
函数参数arguments是类数组,但不是数组。(arguments是对象)
如果希望转成真正的数组,则可以
var slice = [].slice;
slice.call(arguments);
也可以:Aarray.prototype.slice.call(arguments);
基础介绍
js进行函数调用时,除了指定的参数外,还创建一个隐含的对象——arguments。
一、arguments可以用arguments[index]这样的语法取值,拥有长度属性length。arguments对象存储的是实际传递给函数的参数,而不局限于函数声明所定义的参数列表,例如:
代码运行时会依次显示:1,2,1,2,3,4。函数定义了两个参数,但是在调用的时候传递了4个参数。
二、arguments的callee属性
它表示对函数对象本身的引用,这有利于实现无名函数的递归或者保证函数的封装性。例如:用递归来计算1到n的自然数之和:
arguments.callee表示引用当前正在执行的函数,或者说是调用arguments.callee的函数对象的引用,它给匿名函数提供了一种自我引用的方式。
更深入,包括了caller, call, apply
2014-6-10 自己构造一个Array like
类数组的构成要点:
1,元素是数组式索引
2,有length属性
var test3 = { 0 : 10, 1 : function(){ return this[0]; }, length:2 } console.log(Array.prototype.slice.call(test3));//打印[10, function()]
2014-6-9
函数参数arguments是类数组,但不是数组。(arguments是对象)
如果希望转成真正的数组,则可以
var slice = [].slice;
slice.call(arguments);
也可以:Aarray.prototype.slice.call(arguments);
var o = { name:"javascript" }; var f1 = function(){ return 2; } var foo = function(a,b,c){ console.log(arguments, typeof arguments, $.type(arguments), typeof arguments.push); //[100, function(), Object { name="javascript"}] object object undefined //尽管arguments不是数组,但仍可以通过for循环取出每一个元素 for (var i in arguments ){ console.log(arguments[i]); } /*打印 100 function() Object { name="javascript"} */ //现在让数组的slice运行在arguments的context中,参数为0,则将arguments转成了数组,(arguments本身没变) var ret = Array.prototype.slice.call(arguments); console.log(ret, typeof ret, $.type(ret), typeof ret.push); //[100, function(), Object { name="javascript"}] object array function } foo(100,f1,o);
基础介绍
js进行函数调用时,除了指定的参数外,还创建一个隐含的对象——arguments。
一、arguments可以用arguments[index]这样的语法取值,拥有长度属性length。arguments对象存储的是实际传递给函数的参数,而不局限于函数声明所定义的参数列表,例如:
function func(a,b){ alert(a); alert(b); for(var i=0;i<arguments.length;i++){ alert(arguments[i]); } } func(1,2,3,4);
代码运行时会依次显示:1,2,1,2,3,4。函数定义了两个参数,但是在调用的时候传递了4个参数。
二、arguments的callee属性
它表示对函数对象本身的引用,这有利于实现无名函数的递归或者保证函数的封装性。例如:用递归来计算1到n的自然数之和:
var sum=function(n){ if(1==n) { return 1; } else { return n + arguments.callee(n-1); } } alert(sum(100));
arguments.callee表示引用当前正在执行的函数,或者说是调用arguments.callee的函数对象的引用,它给匿名函数提供了一种自我引用的方式。
更深入,包括了caller, call, apply
/* * 演示arguments的用法,如何获取实参数和形数数 */ function argTest(a,b,c,d){ var numargs = arguments.length; // 获取被传递参数的数值。 var expargs = argTest.length; // 获取期望参数的数值。 alert("实参数目为:"+numargs) alert("形数数目为:"+expargs) alert(arguments[0]) alert(argTest[0]) //undefined 没有这种用法 } //argTest(1,2) //argTest(1,2,3,4,5) /* * arguments不是数组(Array类) */ Array.prototype.selfvalue = 1; function testAguments(){ alert("arguments.selfvalue="+arguments.selfvalue); } //alert("Array.sefvalue="+new Array().selfvalue); // 1 //testAguments(); //arguments.selfvalue = undefined /* * 演示函数的callee属性. * 说明:arguments.callee:初始值就是正被执行的 Function 对象,用于匿名函数 */ function calleeDemo() { alert(arguments.callee); } //calleeDemo(); //(function(arg0,arg1){alert("形数数目为:"+arguments.callee.length)})(); /* * 演示函数的caller属性. * 说明:(当前函数).caller:返回一个对函数的引用,该函数调用了当前函数 */ function callerDemo() { if (callerDemo.caller) { var a= callerDemo.caller.arguments[0]; alert(a); } else { alert("this is a top function"); } } function handleCaller() { callerDemo(); } //callerDemo(); //handleCaller("参数1","参数2"); /* * 演示apply,call函数的用法 * 说明:作用都是将函数绑定到另外一个对象上去运行,两者仅在定义参数方式有所区别: * apply(thisArg,argArray); * call(thisArg[,arg1,arg2…] ]); * 即所有函数内部的this指针都会被赋值为thisArg */ function ObjectA(){ alert("执行ObjectA()"); alert(arguments[0]); alert(this.b);//在ObjectB中用call/apply调用ObjectA时,ObjectB的变量b的值。 this.hit=function(msg){alert(msg)} this.info="我来自ObjectA" } function ObjectB(){ alert("执行ObjectB()"); this.b = '2b'; //调用ObjectA()方法,同时ObjectA构造函数中的所有this就会被ObjectB中的this替代 ObjectA.apply(this,arguments);//ObjectA.call(this); alert(this.info); } //ObjectB('参数0'); var value="global 变量"; function Obj(){ this.value="对象!"; } function Fun1(){ alert(this.value); } //Fun1(); //Fun1.apply(window); //Fun1.apply(new Obj());
发表评论
-
[正则]改变URL中的参数值
2015-05-20 20:37 4357作者:zccst 如果一个URL是:http://www.e ... -
理解JavaScript的单线程运行机制及setTimeout(fn,0)
2015-03-30 17:56 5542zccst整理 阮老师的链接 ... -
延迟自定义函数
2015-03-26 14:02 1021作者:zccst 如果函数内又定义了一个跟自己同名的函数,执 ... -
js语句和表达式
2015-03-11 11:21 678作者:zccst 一直觉得语句和表达式很简单,不需要专门留意 ... -
再次学习try catch finally
2015-03-10 11:26 1727作者:zccst 一、基本介绍 JavaScript的错误 ... -
[201502]封装
2015-02-07 11:59 761作者:zccst 我理解的封装是建立在熟悉面向对象和继承的基 ... -
js运算符优先级
2015-01-26 10:39 2560作者:zccst js运算符优先级也是一个巨大的坑。有时候你 ... -
《JavaScript模式》读书笔记
2015-01-23 11:59 845作者:zccst 第四章:函 ... -
js判断复合数据类型的两种方式(typeof不奏效了)
2014-11-07 17:47 2466作者:zccst typeof认为所有的复合数据类型都是&q ... -
js-闭包(权威指南版)
2014-10-27 18:42 1356作者:zccst //1,闭包是 ... -
js数据类型转换
2014-10-22 10:53 6622作者:zccst 2015-3-27 类 ... -
html5的onhashchange和history历史管理
2014-09-20 08:18 4713作者:zccst 现在的开发,越来越倾向于页面内跳转,这种情 ... -
Javascript语言精粹-毒瘤和糟粕
2014-09-16 18:37 1173作者:zccst Javascript是一门语言,用久了肯定能 ... -
[夏天Object]运行时程序执行的上下文堆栈(一)
2014-07-01 22:26 1533作者:zccst 时间:2014-07-01 这已经是第二 ... -
[Object]继承(经典版)(五)封装
2014-06-18 22:21 1050作者:zccst 封装已经上升到写插件的水平了,与多重继承属 ... -
[Object]继承(经典版)(四)多重继承和组合继承
2014-06-18 22:16 1537作者:zccst 一、多重继承 不得不说,这又是异常精彩的 ... -
[Object]继承(经典版)(三)继承理论总结
2014-06-18 22:15 1227作者:zccst 更新:在JavaScript模式中,作者 ... -
[Object]继承(经典版)(二)原型链(原型继承)
2014-06-18 22:05 1026作者:zccst 毫不夸张的说,这节是继承的核心所在。是重中 ... -
[Object]继承(经典版)(一)对象冒充和Call
2014-06-18 21:51 2500作者:zccst 先臆想一下这种方法 var a = ... -
[Object]面向对象编程(高程版)(0)属性和方法
2014-06-16 23:04 927zccst转载+原创 function Person() ...
相关推荐
前端开源库-arguments-extended参数扩展,用于处理参数对象的实用程序
资源来自pypi官网。 资源全名:flake8-force-keyword-arguments-1.0.2.tar.gz
validate-arguments-js 验证参数,声明性的。安装 npm install validate-arguments 代码本身取决于lodash ,并且可以使用require.js在浏览器中require.js 。文献资料该模块lodash一些验证方法,但是通过为您提供了...
js代码-arguments.callee
移位参数 移动 javascript 函数参数以更好地与不同框架集成 npm install shift-arguments用法删除参数 var shiftArguments = require('shift-arguments');function testFunc (result) {}function doSthAsync ...
npm install flat-arguments --save 用法 正常参数 var flatten = require ( 'flat-arguments' ) ; function letsDoThis ( ) { var args = flatten ( arguments ) ; // args = ['arg1', 'arg2'] } letsDoThis ( ...
一个用于解析命令行参数的简单库。 com.audienceproject/simple-arguments_2.12/1.0.1/simple-arguments_2.12-1.0.1.jar
$ npm install mux-arguments 用法 const mux = require ( 'mux-arguments' ) function muxDemux ( arg1 , arg2 , arg3 ) { mux ( obj => { arguments . length === 1 // true demux . apply ( null , arguments ...
一个用于解析命令行参数的简单库。 com.audienceproject/simple-arguments_2.11/1.0.0/simple-arguments_2.11-1.0.0.jar
small code to explain the mimo behavior
关于网络中端到端设计的一篇很好的论文~~~大家可以轻松获得
计算机网络中端到端论点的经典论文 作者:J.H. Saltzer, D.P. Reed and D.D. Clark M.I.T. Laboratory for Computer Science
安装 npm i manage-arguments --savenpm test用法有关更多用例,请参阅 var manageArguments = require ( 'manage-arguments' )function fixture ( ) { return manageArguments ( arguments )}console . log ( ...
一个用于解析命令行参数的简单库。 com.audienceproject/simple-arguments_2.12/1.0.2/simple-arguments_2.12-1.0.2.jar
npm install reverse-arguments 用法 基本用法 var reverse = require ( 'reverse-arguments' ) ; function join ( ) { return Array . prototype . slice . call ( arguments ) . join ( ',' ) ; } join ( 1 , 2...
JS:arguments
jscodeshift -t js-codemod/transforms/arrow-function-arguments.js arrow-function 变换回调只有当它能够保证它不会打破this在功能方面。 function() { }.bind(this)调用转换为() => {} 。 jscodeshift -t js
var isArguments = require ( 'is-arguments' ) ; var assert = require ( 'assert' ) ; assert . equal ( isArguments ( { } ) , false ) ; assert . equal ( isArguments ( [ ] ) , false ) ; ( function ( ) { ...
JS-YAML-适用于JavaScript的YAML 1.2解析器/编写器 这是的实现, 是一种人类友好的数据序列化语言。 从端口开始,它已完全从头开始重写。 现在速度非常快,并且支持1.2规格。 安装 用于node.js的YAML模块 npm ...