-
Notifications
You must be signed in to change notification settings - Fork 664
Underscore Object
Andrey Gershun edited this page Jan 18, 2016
·
2 revisions
Source: StackOverflow
I have the following object and I would like to call it's function.
[{a:1, fn:function(){} }]
Now I know if the object would be nested ([{a:1, b:{fn:function(){} } }]
) that I could do b->fn()
but how do I do it when it's direct property of the first element?
Please use _ variable. This is a pseudo-variable, which includes the record whole itself:
SELECT _->fn() FROM ...
Here is the example:
var data = [
{a:1, fn:function(){return 10}},
{a:2, fn:function(){return 20}},
]
var res = alasql('SELECT _->fn() AS b FROM ?',[data]);
will returs:
[{"b":10},{"b":20}]
You can play with it in jsFiddle
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo