Skip to content

Instantly share code, notes, and snippets.

@ben-ng
Created March 24, 2017 18:32
Show Gist options
  • Save ben-ng/fc0a63ed58dd2fd130f09c6d2cda49b9 to your computer and use it in GitHub Desktop.
Save ben-ng/fc0a63ed58dd2fd130f09c6d2cda49b9 to your computer and use it in GitHub Desktop.
Salesforce Marketing Cloud constructor-from-closure bug
function newEnv () {
function Foo () {
Write('Hello World');
};
var f = {
Foo: Foo
}
return f;
}
var env = newEnv();
var foo = new env.Foo(); // Fails with "env.Foo is not a Type"
function newEnv () {
function Foo () {
Write('Hello World');
};
var f = {
Foo: Foo
}
return f;
}
var env = newEnv();
var Foo = env.Foo; // Assign to a new variable
var foo = new Foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment