JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container"></div>
JavaScript
var myPaper = Raphael('container', '800', '600');
var myScene = function() {
var c1 = myPaper.circle(50, 50, 40);
var c2 = myPaper.circle(50, 150, 40);
var c3 = myPaper.circle(50, 250, 40);
c2.attr("fill", "red"); // yep!
return {
firstCircle: circ1
};
}
myScene();
// then later I want to refer to one of the circles
// without creating another global variable
console.log(myScene.firstCircle); // undefined!
myScene.firstCircle.attr("fill", "red"); // nope!