Most Popular Articles

JavaScript LogoJavaScript Interview Questions: Object-Oriented JavaScript

Typical questions Object-Oriented JavaScript that are asked in job interviews.


JavaScript Logo

What is the difference between a back end and a front end web programming language?

You may have heard the terms “Back End” or “Front End” with regards to web development languages. Some may find this all confusing, but there is not too much mystery to it at all.

In the most basic terms, the moniker says it all: a back language runs on the server and does all its work before the page gets to you. By the time you are looking at the web page, any back end technology that was used to construct and then serve up the page is no longer involved. A front end language operates on the client side. It works in your browser and does not do anything until the page and it associated assets comes over the wire.

READ FULL POST


Angular LogoAngular.js Basics: Routes Part III: Creating a Default Route

Learn how to create a default view in your Angular single-page app.

In Part II of this series: “Angular.js Basics: Routes Part II: Partials“, we learned how to leverage partials in order to decouple our HTML from the associated controllers. This not only proved to be fairly simple, but it also helps to keep our JavaScript code easier to manage and allows us to create HTML templates that can support a higher degree of complexity.

READ FULL POST


Node LogoMaking a Simple HTTP Server with Node.js – Part III

Learn how to leverage the path and file-system Node.js modules to handle requests for files that do not exist, or provide a default.

In Part II of this series: Making a Simple HTTP Server with Node.js – Part II we learned how to use the “path” and “file system” modules. By leveraging these Node.js modules, we were able to read the path of the HTTP request that our server received, and read from the file system of the web server. We also learned about the “__dirname” keyword, which provides an abstract reference to the folder in which the currently executing JavaScript file exists.

READ FULL POST


JavaScript Logo

Associative Arrays in JavaScript

You may have heard conflicting information about associative arrays in JavaScript. This post will clarify that mystery for you, and explain some odd behavior that you have have experienced.

If you are frustrated because you have been getting different answers on this subject, I”ve got good news and bad news. The good news is, the answer is simple: associative arrays are not supported in JavaScript. Arrays in JavaScript are index-based. Plain and simple, end of conversation. The bad new is, it’s not quite the end of the conversation.


READ FULL POST

JavaScript Logo

Two Ways to Dynamically Append an Element to a JavaScript Array

There are two ways to dynamically add an element to the end of a JavaScript array.

I’ve been providing some candidate pre-screening services for recruiters recently, and one of the classic JavaScript interview questions is: “Name two ways to dynamically append an element to a JavaScript array.” Some folks nail that question, but some are left scratching their heads. So I thought I’d quickly re-visit the logic behind this concept.

READ FULL POST


Node Logo

 Making a Simple HTTP Server with Node.js – Part IV

Learn how to set a list of supported mime types for your Node.js server, and set request headers accordingly for each asset served.

In Part III of this series, we built out our Node.js server to serve up any file that is requested, or gracefully return a 404 / “Not Found” header, as well as a custom HTML page informing the user that the requested file was not found. The only problem is that we are not setting headers for each request. It is important that HTML, CSS, JavaScript and image file, have the appropriate “Content-Type” header set.

READ FULL POST


JavaScript Logo

JavaScript Array Management with Push(), Pop(), Shift() and Unshift()

When you need to work with the first or last elements in a JavaScript array, the push(), pop(), shift() and unshift() methods are usually the best way to go.

Programmers who are new to JavaScript or come to it via languages such as PHP may find arrays a bit limiting. The main issue is usually the fact that in JavaScript, there are no associative arrays. While that may seem frustrating, associative array-like functionality can be achieved by leveraging the power and simplicity of objects. Although JavaScript arrays are restricted to numeric-based property names, they are otherwise quite flexible.

READ FULL POST


JavaScript Logo

What’s the difference between jQuery.ajax(), jQuery.get() and jQuery.post()?

jQuery offers three Ajax calls that are simple and painless

Although it is a good idea to understand Ajax in the context of native JavaScript, leveraging the power of JavaScript libraries for your Ajax calls is not a bad idea. Depending on the size and complexity of your application, it can often minimize the amount of code you need to write in order to provide the best cross-browser experience.

READ FULL POST


Angular LogoAngular.js Data-Binding Basics: the ng-model Directive (Part I)

Data-binding with Angular.js is surprisingly simple. To get started, you need only specify an ng-model directive.

One of the most common tasks for any JavaScript developer is to inject a value into the DOM. This value can be a variable or the property of an object. When doing so, you need to make a reference to the target element, and then use a native JavaScript or jQuery method to inject that value (e.g. [SOME_ELEMENT].innerHTML or $(SOME_ELEMENT).html() ). But if that value is injected into more than one element, your work grows exponentially. You now have to manage multiple DOM element references, write code that makes the injections, and also code that pays attention to the data you are working with, so that when that data changes, you can update the DOM element(s) that need to know about that update.

READ FULL POST


JavaScript Logo

What is the difference between an Object Literal and an Instance Object in JavaScript ?

Although a JavaScript object literal and a JavaScript instance object are both objects, they differ in their inherent nature and features.

An object literal is “flat”. You create it, you add properties and methods to it, and all of those properties and methods are public. You can mutate any members of that object at any time. A JavaScript object literal does not by-nature provide private scope. But any of the members of an object literal can certainly be a function that is capable of private scope. Object literals are useful because they allow you to create clean name-spaced code that is easy to pass around and consume.

READ FULL POST