dojo.eval

Project owner:?–
Available:since V?

Evaluate some string of JavaScript in global context.

Introduction

Evaluates the given string into window (global) scope rather than in current scope. Use this rather than eval.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<script type="text/javascript">
 dojo.declare('Foo', null, {
   foo: function() {
     eval('var fooBar = "bar"');
   }
 });

 var foo = new Foo();
 foo.foo();
 // This will generate a "ReferenceError fooBar is not defined"
 console.info(fooBar)


 dojo.declare('Bar', null, {
   bar: function() {
     dojo.eval('var barBaz = "baz"');
   }
 });
 var bar = new Bar();
 bar.bar();
 // Show "baz" !
 console.info(barBaz);
</script>

Table of Contents

Error in the documentation? Can’t find what you are looking for? Let us know!