calling eval() in particular context

前端 未结 14 1101
说谎
说谎 2020-11-27 17:05

I have following javaScript \"class\":

A = (function() {
   a = function() { eval(...) };
   A.prototype.b = function(arg1, arg2) { /* do something... */};
}         


        
14条回答
  •  爱一瞬间的悲伤
    2020-11-27 17:46

    Another Bam!

    eval('(function (data) {'+code+'})').call(selector,some_data);
    

    This example will keep yours context and send some data. In my case, is a some DOM selector

提交回复
热议问题