raphael - empty Javascript function? What does it mean? -


Then the short version, which I do not understand, has this line of code:

  (New function ("Paper", "Window", "Document", CD.V.A.)). Call (paper, paper);  

Longer version, see these functions:

  window.onload = function () {var paper = Rafael ("canvas", 640, 480) ; Var btn = document.getElementById ("run"); Var CD = document.getElementById ("code"); (Btn.onclick = function) {paper.clear (); paper.rect (0, 0, 640, 480, 10) .attr ({fill: "#fff", stroke: "none"}) {{ New work ("paper", "window", "document", cd.value). Call (paper, paper);} catch (e) {alert (e.m.sege || e);}}) ); };  

This code is from the field of Raphael, which means that it implements the Raphael libraries. So a line of code at the top that I do not understand (this is in the attempt / gesture expression), to copy the code seems to enter the user who is stored in cd.value in the function . But how is this possible?

You can go to page here:

Two you understand that < Code> new function () What does? It is similar to eval () , it contains a string of JavaScript code - it uses that string to define a function. Then the row you posted will be equal to the following:

  (function (paper, window, document) code in the code {/ * cd.value goes here}}. Paper, paper); More info: 


Comments