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 .
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of self

  • Rails source code analysis (4): Request / Response

    1) Rails defines two abstract class: AbstractRequest and AbstractResponse code is not posted, first take a look at Response. 2) is mainly responsible for the specific ctgi_process.rb main interface is responsible for implementation methods of impleme ...

  • Rails source code analysis (6): ActionController:: Flash

    Flash's role: The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed to the very next action and then cleared out. This is a great way of doing notices and alerts. In fact it is a mecha ...

  • Msxml2.XMLHTTP version problem

    Projects with an import feature prototype.js of Ajax functionality to update the prompt, the code is very simple, do not have the framework of the background on a jsp to output Text, future use of timers and to update the page Ajax.request encountere ...

  • JS after ajax request return of the problem can not be implemented

    1: Send ajax request, in the onComplete, if back when the html contains a javascript, then these javascrip and will not be realized, it does not mean not to implement. This problem has troubled me for a long time, behind the hair and then put this kn ...

  • WEB test summary (architecture, design) the best part

    1, for a total test architecture 1) thin-client, business logic rules in the server-side implementation of the majority. Such as news sites, portals, information websites. 2) fat client, a high security requirements, frequent interaction, complex bus ...

  • Use Ext JS to read the JsonReader complex object json

    Today was how to resolve the following complex json object to the difficult living over a long time .. did not find documentation how to read JsonReader Ways json object (possibly also because of their limited level of E the text did not correctly underst

  • NoClassDefFoundError: javax / servlet / Servlet

    In the project in order to achieve a listener in web.xml set up a listener, did start in Tomcat actually occurred after java.lang.NoClassDefFoundError: javax / servlet / ServletContextListener this anomaly google and found the reasons for the lack of serv

  • jboss ejb3 Message Driven Bean

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries