{"id":10739,"date":"2011-11-17T21:02:59","date_gmt":"2011-11-17T13:02:59","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=10739"},"modified":"2025-04-04T00:44:02","modified_gmt":"2025-04-03T16:44:02","slug":"node-js-server-side-javascript","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/","title":{"rendered":"Beginner&#8217;s Guide to Node.js (Server-side JavaScript)"},"content":{"rendered":"<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Nodejs\">Node.js<\/a> \u2013 in simple words \u2013 is <strong>server-side JavaScript<\/strong>. It has been getting a lot of buzzes these days. If you\u2019ve heard of it or you\u2019re interested in learning and getting some hands on it \u2013 this post is for you.<\/p>\n<p>So, what exactly is the need to use JavaScript in the server? To make the concept of Node.js clear, I would like to compare it with ordinary server-side languages such as PHP. Node.js uses an <strong>event-based server execution procedure<\/strong> rather than the multithreaded execution in PHP.<\/p>\n<p>To explain it further, we\u2019ll be talking about the idea of <strong>what Node.js is<\/strong> along with some <strong>hosting provider suggestions and installation tips<\/strong>. Intermediate-level knowledge of JavaScript, jQuery, and Ajax is required, but we\u2019ll also provide examples for you to understand the entire thing easier and even work on it, so let\u2019s get to know more about Node.js!<\/p>\n<h2>Let\u2019s consider a case:<\/h2>\n<p>Consider a website in which you need to load content dynamically from another web server that is slow. In PHP you can do it in 2 ways \u2013 <strong>coding it in a simple file<\/strong> and <strong>coding it as another script<\/strong>, then <strong>executing it in a multithreaded approach<\/strong>.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/node-js\/multi-threaded-execution.jpg\" alt=\"multi-threaded execution\" width=\"500\" height=\"286\"><\/figure>\n<p>In the first method, even though the code is simple <strong>the execution pauses for a while<\/strong> at the point where the slow web server is accessed. The second method is <strong>more optimized in case of performance<\/strong>, but it\u2019s hard to code, and it has a multithread management overhead. The case is similar for most of the web programming languages other than server-side JavaScript, i.e., Node.js.<\/p>\n<p><strong>What\u2019s the difference in Node.js?<\/strong> In order to understand Node.js you must keep in mind the <strong>JavaScript\u2019s event-based programming in the browser<\/strong>. We utilize the same technology here. Instead of using a separate thread, a <strong>function is attached to the finish event<\/strong> of the \u201cslow web server access\u201d mentioned above thus, you get the <strong>full functionality<\/strong> in the optimized second option mentioned above without any multithread overhead.<\/p>\n<h2>Getting started with Node.js<\/h2>\n<p><strong>Node.js is JavaScript<\/strong>. Why can\u2019t we utilize the event-based functionality of JavaScript in the client to a server? This thought might have led to the development of Node.js.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/node-js\/event-based-execution.jpg\" alt=\"event-based execution\" width=\"500\" height=\"289\"><\/figure>\n<p>That said, the main highlight of Node.js \u2013 <strong>it is event-based asynchronous functions<\/strong>. It uses an <strong>event loop<\/strong> instead of waiting for I\/O operations (accessing external web service, accessing hardware).<\/p>\n<p>Node.js could still <strong>make use of its processing power<\/strong> when the server is waiting for any other operation. This makes Node.js <strong>scalable<\/strong> to millions of concurrent connections.<\/p>\n<h2>How Does JavaScript Run On A Server?<\/h2>\n<p>Node.js works on a <a href=\"https:\/\/bugs.chromium.org\/p\/v8\/issues\/list\">v8 environment<\/a> \u2013 it is a <strong>virtual machine<\/strong> or a <strong>JavaScript engine<\/strong> that runs the JavaScript code, so for hosting you can\u2019t use the ordinary web hosts. You will need the ones that have the <strong>v8 environment<\/strong>.<\/p>\n<p>Here are some provider suggestions for Node.js hosting:<\/p>\n<ol>\n<li><a target=\"_blank\" href=\"https:\/\/www.cloudfoundry.org\/\" rel=\"noopener\">Cloud Foundry<\/a><\/li>\n<li><a target=\"_blank\" href=\"https:\/\/www.npmjs.com\/package\/difio-dotcloud-nodejs\" rel=\"noopener nofollow\">DotCloud<\/a><\/li>\n<\/ol>\n<h2>Installing Node.js<\/h2>\n<p>Node will <strong>work perfectly on Linux, Macintosh, and Solaris operating systems<\/strong>. On Windows you can install it using the <a href=\"https:\/\/www.cygwin.com\/install.html\">Cygwin emulation layer<\/a>. None of the builds in Windows are satisfactory but it is still possible to get something running.<\/p>\n<p><strong>Option 1: Building Node from source.<\/strong><\/p>\n<p>Use <code>make<\/code> to build and install node.js (execute the following on the command line). <strong><a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Getting-Started-Installing-Git\">Git<\/a> is required<\/strong>.<\/p>\n<pre>\r\ngit clone --depth 1 git:\/\/github.com\/joyent\/node.git\r\ncd node\r\ngit checkout v0.4.11\r\nexport JOBS=2\r\nmkdir ~\/local\r\n.\/configure --prefix=$HOME\/local\/node\r\nmake\r\nmake install\r\necho 'export PATH=$HOME\/local\/node\/bin:$PATH' &gt;&gt; ~\/.profile\r\necho 'export NODE_PATH=$HOME\/local\/node:$HOME\/local\/node\/lib\/node_modules' &gt;&gt; ~\/.profile\r\nsource ~\/.profile\r\n<\/pre>\n<p><strong>Option 2: Installing Node.js from Package<\/strong><\/p>\n<p>For Mac users, you can install Node.js as a package from <a href=\"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/\">https:\/\/sites.google.com\/site\/nodejsmacosx\/<\/a> which is pretty self-explanatory.<\/p>\n<h2>Testing Node Installation<\/h2>\n<p>In order to check your successful Node installation we can try out a very simple console \"Hello World\" program. Create a file named \"<em>test.js<\/em>\" and write the following code into it.<\/p>\n<pre>\r\nvar sys = require(\"sys\");\r\nsys.puts(\"Hello World\");\r\n<\/pre>\n<p><strong>Code explanation:<\/strong><\/p>\n<p>It loads the <code>sys<\/code> class into a variable <code>sys<\/code>. It then uses the <code>sys<\/code> object to perform the console tasks. The <code>sys.puts<\/code> is a command similar to the <code>cout<\/code> in C++, so in order to run the script above go to the command prompt and run it by the command below:<\/p>\n<pre>\r\nnode test.js\r\n<\/pre>\n<p>If your installation is successful then you will get a hello world output in the screen.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/node-js\/nodejs-hello-world.jpg\" width=\"227\" height=\"63\" alt=\"hello world\"><\/figure>\n<h2>Creating a HTTP Server<\/h2>\n<p>Now it\u2019s time to create a \"Hello World\" via web server using Node.js. Here\u2019s what we are going to do \u2013 we <strong>create a server that outputs a \u201cHello World\u201d to the localhost on the port 8080<\/strong> no matter what the URL is, giving you an idea what <strong>event<\/strong> is.<\/p>\n<p><strong>The codes:<\/strong><\/p>\n<pre>\r\nvar sys = require(\"sys\"),\r\nmy_http = require(\"http\");\r\nmy_http.createServer(function(request,response){\r\n\tsys.puts(\"I got kicked\");\r\n\tresponse.writeHeader(200, {\"Content-Type\": \"text\/plain\"});\r\n\tresponse.write(\"Hello World\");\r\n\tresponse.end();\r\n}).listen(8080);\r\nsys.puts(\"Server Running on 8080\");\t\r\n<\/pre>\n<p><strong>Code explanation:<\/strong><\/p>\n<p>The most interesting part in Node.js is its event-based programming. In order to create a HTTP server we need the <strong>HTTP library<\/strong>, so we go forward and add it using <code>my_http<\/code>. We create server by the function:<\/p>\n<pre>\r\nmy_http.createServer(function(request,response){}).listen(8080);\r\n<\/pre>\n<p>The function given as the first argument is executed <strong>every time an event is triggered in port 8080<\/strong>, so the function itself <strong>suggests the node to listen for an event in port 8080<\/strong>. In order to detect this, I have added a \u201c<em>I got kicked<\/em>\u201d message which will be displayed on the console screen whenever a request is received.<\/p>\n<p>The <code>request<\/code> object contains <strong>all the information about the request that has been made to the server<\/strong>. For example it contains the URL string. The <code>response<\/code> object is the object that <strong>handles the response from the server<\/strong>. First we set the header of the response as a <code>text\/plain<\/code> content, then outputs \u201c<em>Hello World<\/em>\u201c, then end the output stream. <em>200<\/em> is the status response.<\/p>\n<p>Well, the above one is a very simple example but we can see that whatever URL we give in the browser for the same server we get the same output like \u201cHello World\u201d.<\/p>\n<h2>Creating simple static file server<\/h2>\n<p>Let\u2019s create a simple static file server in the next tutorial.<\/p>\n<p><strong>The codes:<\/strong><\/p>\n<pre>\r\nvar sys = require(\"sys\"),\r\nmy_http = require(\"http\"),\r\npath = require(\"path\"),\r\nurl = require(\"url\"),\r\nfilesys = require(\"fs\");\r\nmy_http.createServer(function(request,response){\r\n\tvar my_path = url.parse(request.url).pathname;\r\n\tvar full_path = path.join(process.cwd(),my_path);\r\n\tpath.exists(full_path,function(exists){\r\n\t\tif(!exists){\r\n\t\t\tresponse.writeHeader(404, {\"Content-Type\": \"text\/plain\"});  \r\n\t\t\tresponse.write(\"404 Not Found\\n\");  \r\n\t\t\tresponse.end();\r\n\t\t}\r\n\t\telse{\r\n\t\t\tfilesys.readFile(full_path, \"binary\", function(err, file) {  \r\n\t\t\t     if(err) {  \r\n\t\t\t         response.writeHeader(500, {\"Content-Type\": \"text\/plain\"});  \r\n\t\t\t         response.write(err + \"\\n\");  \r\n\t\t\t         response.end();  \r\n\t\t\t   \r\n\t\t\t     }  \r\n\t\t\t\t else{\r\n\t\t\t\t\tresponse.writeHeader(200);  \r\n\t\t\t        response.write(file, \"binary\");  \r\n\t\t\t        response.end();\r\n\t\t\t\t}\r\n\t\t\t\t\t \r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n}).listen(8080);\r\nsys.puts(\"Server Running on 8080\");\t\t\t\r\n<\/pre>\n<p><strong>Codes explanation:<\/strong><\/p>\n<p>The above code is pretty simple, we will discuss it as blocks.<\/p>\n<pre>\r\nvar sys = require(\"sys\"),\r\nmy_http = require(\"http\"),\r\npath = require(\"path\"),\r\nurl = require(\"url\"),\r\nfilesys = require(\"fs\");\r\n<\/pre>\n<p>All these libraries are required for the program. Its usage will be clear in the following code.<\/p>\n<pre>\r\nvar my_path = url.parse(request.url).pathname;\r\nvar full_path = path.join(process.cwd(),my_path);\r\n<\/pre>\n<p>The <code>request<\/code> object has the request details as we have discussed earlier. We use the <code>parse<\/code> function of the URL class which we have included to get the <code>pathname<\/code> of the request URL. After getting the pathname we concatenate it with the path of the current working directory in order to get the full path of the file.<\/p>\n<p>For joining URLs we have a function called <code>join<\/code> in the path library.<\/p>\n<pre>\r\npath.exists(full_path,function(exists){\r\n<\/pre>\n<p>After getting the full path we check whether the path exists by the function <code>exists<\/code>. After the check is done the callback function is called and passed as the second argument.<\/p>\n<pre>\r\nif(!exists){\r\n\tresponse.writeHeader(404, {\"Content-Type\": \"text\/plain\"});  \r\n\tresponse.write(\"404 Not Found\\n\");  \r\n\tresponse.end();\r\n}\r\nelse{\r\n\tfilesys.readFile(full_path, \"binary\", function(err, file) {  \r\n\t\t if(err) {  \r\n\t\t\t response.writeHeader(500, {\"Content-Type\": \"text\/plain\"});  \r\n\t\t\t response.write(err + \"\\n\");  \r\n\t\t\t response.end();  \r\n\t   \r\n\t\t }  \r\n\t\t else{\r\n\t\t\tresponse.writeHeader(200);  \r\n\t\t\tresponse.write(file, \"binary\");  \r\n\t\t\tresponse.end();\r\n\t\t}\r\n\t\t\t \r\n\t});\r\n}\r\n<\/pre>\n<p>Now in the callback function if the file does not exist we send a \"<em>404 Page Not Found<\/em>\" error.<\/p>\n<p>If the page is found then we read the file by the <code>readFile<\/code> function in file system. We can also see the callback function for the <code>readFile<\/code> function defined there itself. If there is no error in reading the file then it will be displayed. If there is an error then a status 500 is returned with the error text.<\/p>\n<p>I also recommend wrapping codes of the previous tutorial into a function so that you can use it in the next tutorial or for future use.<\/p>\n<pre>\r\nvar sys = require(\"sys\"),\r\nmy_http = require(\"http\"),\r\npath = require(\"path\"),\r\nurl = require(\"url\"),\r\nfilesys = require(\"fs\");\r\nmy_http.createServer(function(request,response){\r\n\tvar my_path = url.parse(request.url).pathname;\r\n\tvar full_path = path.join(process.cwd(),my_path);\r\n\tpath.exists(full_path,function(exists){\r\n\t\tif(!exists){\r\n\t\t\tresponse.writeHeader(404, {\"Content-Type\": \"text\/plain\"});  \r\n\t\t\tresponse.write(\"404 Not Found\\n\");  \r\n\t\t\tresponse.end();\r\n\t\t}\r\n\t\telse{\r\n\t\t\tfilesys.readFile(full_path, \"binary\", function(err, file) {  \r\n\t\t\t     if(err) {  \r\n\t\t\t         response.writeHeader(500, {\"Content-Type\": \"text\/plain\"});  \r\n\t\t\t         response.write(err + \"\\n\");  \r\n\t\t\t         response.end();  \r\n\t\t\t   \r\n\t\t\t     }  \r\n\t\t\t\t else{\r\n\t\t\t\t\tresponse.writeHeader(200);  \r\n\t\t\t        response.write(file, \"binary\");  \r\n\t\t\t        response.end();\r\n\t\t\t\t}\r\n\t\t\t\t\t \r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n}\r\nmy_http.createServer(function(request,response){\r\n\tvar my_path = url.parse(request.url).pathname;\r\n\tload_file(my_path,response);\r\n}).listen(8080);\r\nsys.puts(\"Server Running on 8080\");\t\t\t\r\n<\/pre>\n<p>That\u2019s all. Hope this gives you a good idea of Node.js. In the next article, I\u2019ll be showing you how to <strong>load and display number of Facebook likes using Node.js<\/strong>. Stay tuned!<\/p>","protected":false},"excerpt":{"rendered":"<p>Node.js \u2013 in simple words \u2013 is server-side JavaScript. It has been getting a lot of buzzes these days. If you\u2019ve heard of it or you\u2019re interested in learning and getting some hands on it \u2013 this post is for you. So, what exactly is the need to use JavaScript in the server? To make&hellip;<\/p>\n","protected":false},"author":216,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[4117,4616,286],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Beginner&#039;s Guide to Node.js (Server-side JavaScript) - Hongkiat<\/title>\n<meta name=\"description\" content=\"Node.js - in simple words - is server-side JavaScript. It has been getting a lot of buzzes these days. If you&#039;ve heard of it or you&#039;re interested in\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Beginner&#039;s Guide to Node.js (Server-side JavaScript)\" \/>\n<meta property=\"og:description\" content=\"Node.js - in simple words - is server-side JavaScript. It has been getting a lot of buzzes these days. If you&#039;ve heard of it or you&#039;re interested in\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2011-11-17T13:02:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-03T16:44:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/node-js\/multi-threaded-execution.jpg\" \/>\n<meta name=\"author\" content=\"Geo Paul\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Geo Paul\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/\"},\"author\":{\"name\":\"Geo Paul\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/96b9e48d0d487d6f8f43a8b73e8a2304\"},\"headline\":\"Beginner&#8217;s Guide to Node.js (Server-side JavaScript)\",\"datePublished\":\"2011-11-17T13:02:59+00:00\",\"dateModified\":\"2025-04-03T16:44:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/\"},\"wordCount\":1224,\"commentCount\":69,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/node-js\\\/multi-threaded-execution.jpg\",\"keywords\":[\"Javascripts\",\"NodeJS\",\"tutorials\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/\",\"name\":\"Beginner's Guide to Node.js (Server-side JavaScript) - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/node-js\\\/multi-threaded-execution.jpg\",\"datePublished\":\"2011-11-17T13:02:59+00:00\",\"dateModified\":\"2025-04-03T16:44:02+00:00\",\"description\":\"Node.js - in simple words - is server-side JavaScript. It has been getting a lot of buzzes these days. If you've heard of it or you're interested in\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/node-js\\\/multi-threaded-execution.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/node-js\\\/multi-threaded-execution.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/node-js-server-side-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Beginner&#8217;s Guide to Node.js (Server-side JavaScript)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/96b9e48d0d487d6f8f43a8b73e8a2304\",\"name\":\"Geo Paul\",\"description\":\"Geo is an independent Web\\\/iPhone developer who enjoys working with PHP, Codeigniter, WordPress, jQuery, and Ajax. He has 4 years of experience in PHP and 2 years of experience in iOS application development.\",\"sameAs\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/geopaul\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Beginner's Guide to Node.js (Server-side JavaScript) - Hongkiat","description":"Node.js - in simple words - is server-side JavaScript. It has been getting a lot of buzzes these days. If you've heard of it or you're interested in","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Beginner's Guide to Node.js (Server-side JavaScript)","og_description":"Node.js - in simple words - is server-side JavaScript. It has been getting a lot of buzzes these days. If you've heard of it or you're interested in","og_url":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2011-11-17T13:02:59+00:00","article_modified_time":"2025-04-03T16:44:02+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/node-js\/multi-threaded-execution.jpg","type":"","width":"","height":""}],"author":"Geo Paul","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Geo Paul","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/"},"author":{"name":"Geo Paul","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/96b9e48d0d487d6f8f43a8b73e8a2304"},"headline":"Beginner&#8217;s Guide to Node.js (Server-side JavaScript)","datePublished":"2011-11-17T13:02:59+00:00","dateModified":"2025-04-03T16:44:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/"},"wordCount":1224,"commentCount":69,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/node-js\/multi-threaded-execution.jpg","keywords":["Javascripts","NodeJS","tutorials"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/","url":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/","name":"Beginner's Guide to Node.js (Server-side JavaScript) - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/node-js\/multi-threaded-execution.jpg","datePublished":"2011-11-17T13:02:59+00:00","dateModified":"2025-04-03T16:44:02+00:00","description":"Node.js - in simple words - is server-side JavaScript. It has been getting a lot of buzzes these days. If you've heard of it or you're interested in","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/node-js\/multi-threaded-execution.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/node-js\/multi-threaded-execution.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/node-js-server-side-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Beginner&#8217;s Guide to Node.js (Server-side JavaScript)"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/96b9e48d0d487d6f8f43a8b73e8a2304","name":"Geo Paul","description":"Geo is an independent Web\/iPhone developer who enjoys working with PHP, Codeigniter, WordPress, jQuery, and Ajax. He has 4 years of experience in PHP and 2 years of experience in iOS application development.","sameAs":["https:\/\/www.hongkiat.com\/blog\/"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/geopaul\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-2Nd","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/216"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=10739"}],"version-history":[{"count":3,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10739\/revisions"}],"predecessor-version":[{"id":73509,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/10739\/revisions\/73509"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=10739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=10739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=10739"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=10739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}