Question: does anyone know a little trick to replace the argument for a return function with a function declaration? return function () { } to return function cheese () { }

Asked By
Asked At
2017-10-10 16:07:09

Found 15 possible answers.

User Answered At Possible Answer
loganfsmyth 2017-10-10 16:08:28 that's not a function declaration FYI :slightly_smiling_face: just a named function expression no tricks needed as long as you have a good name to give it that won't conflict with any existing code you should be able to assign a .id property on the function to create a name if you want one
wagonofjustice 2017-10-10 16:11:45 :0 what's a function declaration? great, thank you
loganfsmyth 2017-10-10 16:12:14 = t.identifier("cheese")
wagonofjustice 2017-10-10 16:12:24 var thing = function ?
loganfsmyth 2017-10-10 16:12:40 a declaration is specifically a function that is in a statement position in our code rather than an expression position
wagonofjustice 2017-10-10 16:13:01 icic hmmm
loganfsmyth 2017-10-10 16:13:10 so
function cheese(){}
is an expression
is a declaration, but 
var cheese = function cheese(){}
wagonofjustice 2017-10-10 16:13:22 ok, super if I have a function expression/declaration and I want to insert a call expression inside it, what's the best way to go about that?
loganfsmyth 2017-10-10 18:21:47 @wagonofjustice you'd add a new item to the .body.body array
drewml 2017-10-10 19:31:09 huh, apparently a new JSX spec change -
hzoo 2017-10-10 19:31:29 yea
drewml 2017-10-10 19:31:35 (ah, just noticed Logan was already looking at it)
hzoo 2017-10-10 19:31:45 some of us got pinged
drewml 2017-10-10 19:33:15 is this just to avoid using [] for adjacent nodes without a parent jsxelement?
loganfsmyth 2017-10-10 19:38:50 I think mostly

Related Questions