====== Reactive Programming ====== {{exorciser/jspg?javascript=let%20fs%20%3D%20document.querySelectorAll%28%27textarea%27%29%3B%0A%0Afunction%20update%28%29%20%7B%0A%20%20%20for%20%28let%20f%20of%20fs%29%20%7B%0A%20%20%20%20%2F%2Fconsole.clear%28%29%3B%0A%20%20%20%20let%20code%20%3D%20f.value%3B%0A%20%20%20%20let%20out%20%3D%20document.querySelector%28%60%23o%24%7Bf.id%7D%60%29%0A%20%20%20%20try%20%7B%0A%20%20%20%20%20%20out.innerHTML%20%3D%20eval%28code%29%3B%0A%20%20%20%20%7D%20catch%20%28e%29%20%7B%0A%20%20%20%20%20%20%20%20out.innerHTML%20%3D%20e%0A%20%20%20%20%7D%0A%20%20%7D%20%0A%7D%0AsetInterval%28update%2C%20100%29%0A%0A&css=pre%20%7B%20border%3A%201px%20solid%20lime%3B%7D%0Atextarea%20%7Bwidth%3A%2099%25%3B%7D&html=%3Ctextarea%20id%3D%271%27%20cols%3D64%3Ea%20%3D%2012%3C%2Ftextarea%3E%0A%3Cpre%20id%3D%27o1%27%3E%3C%2Fpre%3E%0A%0A%3Ctextarea%20id%3D2%20cols%3D64%3Eb%20%3D%20c%28a%29%20%2F%2F%20%2B%20b%3C%2Ftextarea%3E%0A%3Cpre%20id%3D%27o2%27%3E%3C%2Fpre%3E%0A%3Ctextarea%20id%3D3%20cols%3D64%3Ec%20%3D%20x%20%3D%3E%20x%2aa%0A%3C%2Ftextarea%3E%0A%3Cpre%20id%3D%27o3%27%3E%3C%2Fpre%3E#1}} ===== Quellen ===== * http://www.squarefree.com/shell/shell.html ===== more... ===== {{exorciser/jspg?javascript=function%20Scope%28%29%20%7B%0D%0A%20%20%22use%20strict%22%3B%0D%0A%20%20this.names%20%3D%20%5B%5D%3B%0D%0A%20%20this.eval%20%3D%20function%28s%29%20%7B%0D%0A%20%20%20%20return%20eval%28s%29%3B%0D%0A%20%20%7D%3B%0D%0A%7D%0D%0A%0D%0AScope.prototype.newNames%20%3D%20function%28%29%20%7B%0D%0A%20%20%22use%20strict%22%3B%0D%0A%20%20var%20names%20%3D%20Array.from%28arguments%29%3B%0D%0A%20%20var%20newNames%20%3D%20names.filter%28%28x%29%20%3D%3E%20%21this.names.includes%28x%29%29%3B%0D%0A%0D%0A%20%20if%20%28newNames.length%29%20%7B%0D%0A%20%20%20%20var%20i%2C%20len%3B%0D%0A%20%20%20%20var%20totalNames%20%3D%20newNames.concat%28this.names%29%3B%0D%0A%20%20%20%20var%20code%20%3D%20%22%28function%28%29%20%7B%5Cn%22%3B%0D%0A%20%20%20%20for%20%28i%20%3D%200%2C%20len%20%3D%20newNames.length%3B%20i%20%3C%20len%3B%20i%2B%2B%29%20%7B%0D%0A%20%20%20%20%20%20code%20%2B%3D%20%27var%20%27%20%2B%20newNames%5Bi%5D%20%2B%20%27%20%3D%20null%3B%5Cn%27%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20code%20%2B%3D%20%27return%20function%28str%29%20%7Breturn%20eval%28str%29%7D%3B%5Cn%7D%29%28%29%27%3B%0D%0A%20%20%20%20this.eval%20%3D%20this.eval%28code%29%3B%0D%0A%20%20%20%20this.names%20%3D%20totalNames%3B%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0A%0D%0A%2F%2F%20LOGGING%20FOR%20EXAMPLE%20RUN%0D%0Afunction%20log%28s%2C%20eval_%2C%20expr%29%20%7B%0D%0A%20%20s%20%3D%20%27%3Cspan%20class%3D%22remark%22%3E%27%20%2B%20String%28s%29%3B%0D%0A%20%20if%20%28expr%29%20%7B%0D%0A%20%20%20%20s%20%2B%3D%20%27%3A%5Cn%3Cb%3E%27%20%2B%20expr%20%2B%20%27%3C%2Fb%3E%20%20%20--%3E%20%20%20%27%3B%0D%0A%20%20%7D%0D%0A%20%20s%20%2B%3D%20%27%3C%2Fspan%3E%27%3B%0D%0A%20%20if%20%28expr%29%20%7B%0D%0A%20%20%20%20try%20%7B%0D%0A%20%20%20%20%20%20s%20%2B%3D%20%27%3Cspan%20class%3D%22result%22%3E%27%20%2B%20JSON.stringify%28eval_%28expr%29%29%20%2B%20%27%3C%2Fspan%3E%27%3B%0D%0A%20%20%20%20%7D%20catch%20%28err%29%20%7B%0D%0A%20%20%20%20%20%20s%20%2B%3D%20%27%3Cspan%20class%3D%22error%22%3E%27%20%2B%20err.message%20%2B%20%27%3C%2Fspan%3E%27%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%7D%0D%0A%20%20document.body.innerHTML%20%2B%3D%20s%20%2B%20%27%5Cn%5Cn%27%3B%0D%0A%7D%0D%0Adocument.body.innerHTML%20%3D%20%27%27%3B%0D%0A%0D%0Avar%20scope%20%3D%20new%20Scope%28%29%3B%0D%0Alog%28%22Evaluating%20a%20var%20statement%20doesn%27t%20change%20the%20scope%20but%20newNames%20does%20%28should%20return%20undefined%29%22%2C%20scope.eval%2C%20%27%20x%20%3D%204%27%29%0D%0Alog%28%22X%20in%20the%20scope%20object%20should%20raise%20%27x%20not%20defined%27%20error%22%2C%20scope.eval%2C%20%27x%27%29%3B%0D%0Alog%28%22X%20in%20the%20global%20scope%20should%20raise%20%27x%20not%20defined%27%20error%22%2C%20eval%2C%20%27x%27%29%3B%0D%0Alog%28%22Adding%20X%20and%20Y%20to%20the%20scope%20object%22%29%3B%0D%0Ascope.newNames%28%27x%27%2C%20%27y%27%29%3B%0D%0Alog%28%22Assigning%20x%20and%20y%22%2C%20scope.eval%2C%20%27x%20%3D%203%3B%20y%20%3D%204%27%29%3B%0D%0Alog%28%22X%20in%20the%20global%20scope%20should%20still%20raise%20%27x%20not%20defined%27%20error%22%2C%20eval%2C%20%27x%27%29%3B%0D%0Alog%28%22X%20%2B%20Y%20in%20the%20scope%20object%20should%20be%207%22%2C%20scope.eval%2C%20%27x%20%2B%20y%27%29%3B%0D%0Alog%28%22X%20%2B%20Y%20in%20the%20global%20scope%20should%20raise%20%27x%20not%20defined%27%20error%22%2C%20eval%2C%20%27x%20%2B%20y%27%29%3B&css=.remark%20%7B%0D%0A%20%20font-style%3A%20italic%3B%0D%0A%7D%0D%0A%0D%0A.result%2C%20.error%20%7B%0D%0A%20%20font-weight%3A%20bold%3B%0D%0A%7D%0D%0A%0D%0A.error%20%7B%0D%0A%20%20color%3A%20red%3B%0D%0A%7D%0D%0A&html=%3Cbody%20style%3D%27white-space%3A%20pre%27%3E%3C%2Fbody%3E#1}} * https://stackoverflow.com/questions/9781285/specify-scope-for-eval-in-javascript * http://perfectionkills.com/global-eval-what-are-the-options/