JavaScript Essentials: Anonymous Functions

preview_player
Показать описание
In this tutorial, you'll learn what an anonymous function is in JavaScript and when and why you might want to use one.

In a previous JavaScript essentials lesson, we looked at how to create functions in different ways and then call those functions to run code at any point in your programs.

We actually did come across a JavaScript anonymous function in that lesson without even realising it. Quite simply, an anonymous function in JavaScript is one which doesn't have an explicit identifier assigned to it.

In the tutorial, i'll highlight how to identify an anonymous function and take you through a specific example where we use the JavaScript built in settimeout function to call an anonymous function. Channel Handle @codebubb
Рекомендации по теме
Комментарии
Автор

Thanks man this has genuinely helped me out cause I kept hearing anonymous function and didn't know what they were

Chike_Odor
Автор

I'm not going to lie, that was surprisingly satisfying to see that "hello, world" pop up in my console after the 2 second delay.

mainaccount
Автор

Short vid and easy to understand. Amazing!!

arturome
Автор

i mean... why put a function there? cant you give the console.log statement directly inside the timeout function?

nihalmurali
Автор

This isn't correct. The function stored in `sayHi` has the name `sayHi` - you can check this by checking the function's `name` property. The act of assigning an anonymous function to a variable gives it a name.

jrandy