mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 10:52:47 +00:00
29 lines
2.5 KiB
HTML
29 lines
2.5 KiB
HTML
<div class="blog-post">
|
|
<h2 class="blog-post-title">Understanding Javascript Callbacks</h2>
|
|
|
|
<p class="blog-post-meta">December 10, 2015 by Mitchell</p>
|
|
|
|
<p>Javascript is a powerful language that is being utilized mainly on the front end of applications as well on the back end. Javascript has become popular as a back end language because it is built around asynchronous functionality and features a non-blocking API, which is known as Node.js. Node.js is a cross-platform runtume environment for developing server-side web applications. This site is currently using Node.js as a back end and server platform.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<p>As I have progressed in college I have become more interested in server side programming. I first started out with PHP and JSP, but I wanted to learn a language that was newer, and I liked the idea of Node.js and it's ease of use when it came to creating restful API's. When I first started venturing into web development, I became familiar with javascript and I easily adapted because of my strong background with Java. I cought on to web development very quickly and I wanted to learn new server side languages besides PHP and JSP. I liked the idea of Node.js because I thought it would be convenient to use Javascript for both the back and and front end as well as the database, but that is another story. I also use MongoDB to store the information for this site, but I will will make another blog post about that in the future.
|
|
</p>
|
|
|
|
<p>I could go on and on about how much I like javascript as a back end programming language, but I wwant to discuss the callback functionality that javascript is very popular for. I want to discuss this because at first I had a hard time understanding the asynchronous functiality of javascript and I would like to help others better understand this concept. Javascript is known as a single threaded language, but it utilizes callbacks within asynchronous functionality to act like a multi-threaded application, which is different than an applications that uses PHP or JSP.
|
|
</p>
|
|
|
|
<p>If you have previously only had experience programming in Java or Python for example you probably have not done much with threading or asynchronous programming. This can make asynchronous javascript functions confusing, because it is probably a new aspect of programming. Because asynchronous Javascript functions have callbacks, all of the proceeding code must be written within the function. I will try to explain this in the examples below.
|
|
</p>
|
|
|
|
<code>
|
|
function print_text(){
|
|
|
|
|
|
}
|
|
|
|
</code>
|
|
|
|
|
|
</div> |