Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript defining functions

I've been learning Javascript with Khan Academy. I'm looking at : http://www.khanacademy.org/cs/speed-circles/964929070

there is a line that reads "var draw = function() {...}" is he defining a function called draw? Or is the variable draw calling some function (which I don't see defined)?

Thanks!

like image 626
user2009020 Avatar asked May 05 '26 15:05

user2009020


1 Answers

Yes, a function expression is being assigned to the variable named draw. You can even call it:

var draw = function() {
    console.log('xyz');
};

draw(); // 'xyz'
like image 127
David G Avatar answered May 08 '26 07:05

David G