{"id":136251,"date":"2024-01-30T14:30:18","date_gmt":"2024-01-30T14:30:18","guid":{"rendered":"https:\/\/www.sushilkumar.ind.in\/blog\/?p=136251"},"modified":"2024-01-30T14:30:20","modified_gmt":"2024-01-30T14:30:20","slug":"what-is-callback-function","status":"publish","type":"post","link":"https:\/\/www.sushilkumar.ind.in\/blog\/javascript\/what-is-callback-function\/","title":{"rendered":"What is callback Function?"},"content":{"rendered":"\n<p>A callback function, in programming, is a function that is passed as an argument to another function and is executed after some operation or event has occurred. Callback functions are commonly used in asynchronous programming, where tasks are performed concurrently and the program doesn&#8217;t wait for one task to finish before moving on to the next.<\/p>\n\n\n\n<p>For example, in JavaScript, a callback function might be passed to an asynchronous function like <code>setTimeout()<\/code> to be executed after a certain delay. Here&#8217;s a simple example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function greet(name, callback) {\n    console.log(\"Hello, \" + name + \"!\");\n    callback(); \/\/ Execute the callback function\n}\n\nfunction sayGoodbye() {\n    console.log(\"Goodbye!\");\n}\n\n\/\/ Using greet() with a callback function\ngreet(\"Alice\", sayGoodbye);<\/code><\/pre>\n\n\n\n<p>In this example, <code>sayGoodbye()<\/code> is a callback function that gets executed after the <code>greet()<\/code> function finishes its operation of printing a greeting message.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A callback function, in programming, is a function that is passed as an argument to another function and is executed after some operation or event has occurred. Callback functions are commonly used in asynchronous programming, where tasks are performed concurrently and the program doesn&#8217;t wait for one task to finish before moving on to the &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[323],"tags":[],"class_list":["post-136251","post","type-post","status-publish","format-standard","","category-javascript"],"jetpack_publicize_connections":[],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p99pkJ-zrB","_links":{"self":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/136251"}],"collection":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/comments?post=136251"}],"version-history":[{"count":1,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/136251\/revisions"}],"predecessor-version":[{"id":136252,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/136251\/revisions\/136252"}],"wp:attachment":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/media?parent=136251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/categories?post=136251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/tags?post=136251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}