Forums > Javascript

Function expression with msg_float() doesn't work

May 30, 2014 | 10:51 pm

Maybe there’s a variety of things wrong with this but I’m trying to figure out why I can’t use msg_float in a function expression. Does anyone understand why?

Does not work:

var mf = function msg_float(x) {
	switch(inlet) {
		case 1:
		post('stuff');
		break;
	}
}
mf(x);

I get the error, "No function msg_float"

Works fine:

function msg_float(x) {
	switch(inlet) {
		case 1:
		post('stuff');
		break;
	}
}

May 31, 2014 | 1:48 am

Hi !

your "msg_float" is private to your newly created function body only . its not in "jsthis" scope .


May 31, 2014 | 2:11 am

#EDIT
: deleted as i was referring to different case

u can use both functions

var mf  = function(x){
	post(x,"\n")
};

var msg_float = mf;
  • This reply was modified 5 months by  do...while.

May 31, 2014 | 11:27 am

Thanks for that clarification.


Viewing 4 posts - 1 through 4 (of 4 total)