if I define a variable in within a function - with...
# cfml-general
g
if I define a variable in within a function - with "var"; Is it in the LOCAL or VARIABLES scope? Thanks!
p
It is a function local scoped variable..
a
@gavinbaumanis that would have been so easy to test for yourself, I wonder about the merits of asking it here.
Or... read the docs...
😄 1
m
var foo = bar; is the same as local.foo=bar;
👍 1
p
NB: LOCAL variables however cannot be used into closure functions
a
Can you give an example of what you mean, @paolo79?
p
a function with this part:
Copy code
var shipUtils = createobject"component","shipUtils").init();

  local.q_orders = queryExecute('
      SELECT *
      FROM TABLE_ORDERS
      WHERE "_businessKey" = :businessKey
    ', {businessKey = {cfsqltype = "varchar", value = arguments.businessKey}});

  queryEach(local.q_orders, function(row, rowIndex, query) {
    local.q_ship = shipUtils.get(bordero = row.BORDERO);
  }