In order to study Currying in Javascript, read a lot of foreign language website, is to find a better Currying program, find the following in more detail (the article may contain internal links to more related articles):

  1. Currying JavaScript Functions
  2. JavaScript Currying Redux
  3. JavaScript currying
  4. functional.js description and source code analysis

Found that most people are used (argments, 0), had not understand what the sentence is. The last revision of the slice () method, then reference (thisArg [, arg1 [, arg2 [, ...]]]) , or do not know (I brain turn slowly: |). Internet search, check first foreigner to in English did not explain, really to find the "Array.prototype.slice use" only when they get a few articles . While I despise people who engage in collecting, and made the Internet a great copy paper like the world like, but now hate less, only three (exactly the same three, editor for the admin or super-administrator, the author is Anonymous. )

Here my understanding, to explain, rookie left, prawn spit:
Update: The following write may be a bit difficult to understand, fear of people who may be new to Javascript can not read, please leave a message after reading it, thank you! (thisArg [, arg1 [, arg2 [, ...]]])

Members on:

Array [object]

Array objects (that is, an array of objects)

prototype [property]

Javascript's prototype, the prototype non-Prototype.js, may for the time being understood as Java, static properties / methods. In short it can not say in detail see JavaScript in the prototype (prototype) Attribute.

slice [Function]

Segmentation of the array, a method useful, concrete look here or there .

call [Function]

Magic method, which is all the Function object in the way, so there is a method of slice. Function object used to replace inside this target. See here .

String up is:

Use human language to say that the Array has a prototype, slice is the prototype of his son, call a slice of his wife (a lot of bricks came.) Please continue to look down.

Effect of: == [].slice

Although the result is a kind of running, but after testing (others to do the test, not me), the efficiency of the former than the latter greatly improved, so it is so applied.

Here is a Function object slice method. Typically, the programmer through the following method call Function, in essence, an ordinary function call method:


As for the call () method, METHOD: Function:: call us, you can[, arg1[, arg2[, ...]]])

In the form of calling a Function object, this object among Replace thisArg, which can be the following code:,begin,end)

Using pseudo-code simulation process:

Well, we use pseudo-code to simulate the entire process:

var mySlice=Array.prototype.slice;

alert(mySlice); //alert: function(begin[,end]){...}, This is a "function  "

var array_empty=mySlice(begin,end); //create a new,empty array

set array_empty=obj; // At this point, bring  obj Assigned to the empty array, the array has a seed  ,
                              // This is the  call() Are doing, "artificial insemination  "

alert(array_empty); // This is not an array of type object, the  Javascript Internal control over  ,
                           // This may be nothing to see, but the outcome of the case  , It must be related with obj  

// The following are the key of a row  :
var array_last=array_empty.slice(begin,end);
* Although before that asensitive  ,
* However, the returned array is an array, we cut  , But what to cut  ?
* Yes, you can take with  obj Created by array conducting cutting  ,
* A new array object produced  !

Similarly, Array.prototype.slice.apply (obj) and similar code can also be understood that, as long as the prototype not interfere on the line. See here do not understand them, please review the Array.slice (begin, End) .

Related Reading:

[1] Array.prototype.slice.apply Tips

[2] Array-like Objects in JavaScript .

分类:Web 时间:2010-08-26 人气:209
blog comments powered by Disqus


  • draggable.js source code analysis 2010-12-01

    /** * draggable - jQuery EasyUI * * Licensed under the GPL: * * * Copyright 2010 stworthy [ ] */ (function($){ // Method of moving variables stored function drag(e){ var opts = $.data(

  • (Transfer) MapReduce source code analysis summary 2011-05-03

    Original Address: Transferred by Note: The summary originally wanted to study in the series of detailed analysis Hadoop HDFS and Map-Reduce, however, when searching for information and found

  • Spring Framework core source code analysis and experience-IOC articles -4 2010-11-13

    From the article, I know we want to get the Bean is instantiated out how, but also know that dependency injection actually occurred in the BeanWrapperImpl this class, and then we look at the implementation of this class (that is applyPropertyValues (

  • Spring source code analysis (6): Spring declarative transaction processing 2009-11-30

    We take a look at Spring's transaction code, the use of Spring Management Services are two kinds of declarative and programmatic way through the AOP declarative transaction management code to achieve the things as a package to horizontal aspects of t

  • Spring source code analysis (8): Spring-driven implementation of Hibernate 2009-03-26

    O / R tool came to simplify the complex information of many persistent development. Spring application developers through the Spring provides O / R program is more convenient to use a variety of persistence tools, such as Hibernate; Here we have Spri

  • Android IPC communication mechanism for source code analysis 2010-06-10

    Android IPC communication mechanism for source code analysis Binder Communications Description: Linux system, inter-process communication methods are: socket, named pipe, message queque, signal, share memory. Java System inter-process communication w

  • (R) linux source code analysis and comparative reading tools 2010-11-01

    Reprinted from: Windows source code under the reading tool Souce Insight by virtue of its ease of use and variety of programming languages, this area is undoubtedly the "take the

  • NMAP-3.75 source code analysis (1. The whole process) 2010-11-03

    From file nmap_main () function begins 307 line: while((arg = getopt_long_only(argc,fakeargv,"6Ab:D:d::e:Ffg:hIi:M:m:NnOo:P:p:qRrS:s:T:Vv", long_options, &option_index)) != EOF) { start parsing command line parameters, according to t

  • (R) linux source code analysis tools, and read more 2010-11-01

    Reprinted from: Reading tool for Windows source code Souce Insight With its ease of use and a variety of programming languages, no doubt in this area, "lead Big Brother." Lin

  • struts2 source code analysis - Request Process 2011-07-19

    Struts2 source code to read - Request Process 2009-06-03 19:49:50 | Category: STRUTS | Tags: | font size medium and small subscription Struts package introduced ( ) (most of the descriptiv

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.193 (s). 12 q(s)