<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pro-Tek Blog &#187; JavaScript: Callback</title>
	<atom:link href="http://www.pro-tekconsulting.com/blog/tag/javascript-callback/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pro-tekconsulting.com/blog</link>
	<description>For UI developers / UI designers and UI trends</description>
	<lastBuildDate>Thu, 05 Sep 2019 03:59:47 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.34</generator>
	<item>
		<title>JAVASCRIPT: CALLBACK</title>
		<link>http://www.pro-tekconsulting.com/blog/javascript-callback/</link>
		<comments>http://www.pro-tekconsulting.com/blog/javascript-callback/#comments</comments>
		<pubDate>Sat, 09 Feb 2019 02:37:38 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JavaScript: Callback]]></category>

		<guid isPermaLink="false">http://www.pro-tekconsulting.com/blog/?p=2913</guid>
		<description><![CDATA[<p>JavaScript: Callback Callback functions is a theory derived from functional programming and specifies the use of functions as arguments. In JavaScript every function is a first class object, which means that every function is an Object and can be used like any other object. This enables the use of a function as a parameter in [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/javascript-callback/">JAVASCRIPT: CALLBACK</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h4>JavaScript: Callback</h4>
<p>Callback functions is a theory derived from functional programming and specifies the use of functions as arguments.</p>
<p>In JavaScript every function is a first class object, which means that every function is an Object and can be used like any other object. This enables the use of a function as a parameter in another function which is the fundamental idea of callback functions.</p>
<p><strong>PARAMETERS TO CALLBACK FUNCTIONS:</strong></p>
<p>We can also pass parameters to callback functions, just similar to any other function. In the below instance we pass as a parameter the name of the author of the function.</p>
<p>var author = “FF”;<br />
function namedCallback(param){<br />
alert(“namedCallback() called by “+param);<br />
}<br />
function testFunction(callback){<br />
callback();<br />
}<br />
testFunction(namedCallback(author));</p>
<p><strong>MULTIPLE CALLBACK FUNCTION:</strong></p>
<p>Multiple callback functions can be used as parameters of another function.</p>
<p>Var someUlr = …;<br />
function successCallback(){<br />
//success code<br />
}<br />
function completeCallback(){<br />
//complete code<br />
}<br />
function errorCallback(){<br />
//error code<br />
}<br />
$.ajax({<br />
url: someUrl,<br />
success: successCallback,<br />
complete: completeCallback,<br />
error: errorCallback<br />
})</p>
<p><strong>WHY DO WE NEED CALLBACKS?</strong></p>
<p>For one very key reason — JavaScript is an event driven language. This means that instead of waiting for a response before moving on, JavaScript will keep executing while listening for other events.</p>
<p>function first(){<br />
console.log(1);<br />
}<br />
function second(){<br />
console.log(2);<br />
}<br />
first();<br />
second();</p>
<p>As the user would expect, the function first is executed first, and the function second is executed second.</p>
<p>// 1<br />
// 2</p>
<p><strong>THE VERDICT </strong></p>
<p>You can now understand what a callback is and how it works. This is just the tip of the iceberg with callbacks, there is still a lot more to learn!</p>
<p>The post <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog/javascript-callback/">JAVASCRIPT: CALLBACK</a> appeared first on <a rel="nofollow" href="http://www.pro-tekconsulting.com/blog">Pro-Tek Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pro-tekconsulting.com/blog/javascript-callback/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
