In the recent post on adding scores in FlowBoost I purposely left out the
var statement when declaring variables to be returned:
I decided to leave out the
varkeyword because you need a property of the global object, and that happens automatically if you omit
var. Keeps the request payload a little shorter.
See, with a Standard mode FlowBoost call, only top-level properties are returned in the FlowBoost response. Both
var personScore = and
personScore = create a top-level property. But
let personScore = and
const personScore = don’t.
Strategically choosing between
const avoids cluttering your JSON response with stuff Marketo won’t care about. Here,
emailParts (in effect temporary variables) are declared with
emailDomain are both
The JSON response will only include the 2 declared with
Why FlowBoost works this way
After your code finishes— in Standard authoring mode, it’s different in Pro — any newly added properties of the context object are sent in the JSON response.
It’s sort of a happy accident that only
var and an undecorated variable declaration create top-level properties . It wouldn’t be so bad for FlowBoost’s purposes if
const also did this (you could just ignore the chaff in the response payload). But these newer statements deliberately don’t touch the global object. So we get to manage payload sizes as a result.