Home » JavaScript (page 59)

JavaScript

Javascript Prototype methods vs Object methods

In JavaScript, when you define an object, you can attach it’s functions in two different ways. Inside object’s constructor function, using this.func = function(){...} Using prototype. i.e. Obj.prototype.func = function() {...}. In both approaches, the function func() will be accessible to all the instances of your object. But which one is the best way to use? In short: Use prototype ...

Read More »

A canonical web test in NodeJS

Working with web applications in NodeJS is great. Using the same language and libraries on the client and server simplified the thinking. And NodeJS has fast tests and restart for a super quick edit-verify cycle when you’re coding. I like to write tests to verify the server-side and client-side logic, but do you know that the whole solution really is ...

Read More »

Integrating Node.js with a C# dll

Recently I had to integrate a Node.js based server application with a C# DLL. Our software (a web-app) offers the possibility to execute payments over a POS terminal. This latter one is controllable through a dedicated DLL which exposes interfaces like ExecutePayment(operation, amount) and so on. As I mentioned, there is the Node.js server that somehow exposes the functionality of ...

Read More »

Things I learnt creating a jQuery Plugin (Part I)

jQuery is one of the most used JavaScript libraries, if not the most used one, which allows to make great things with the big set of little tools it offers to the web developers: HTML/DOM manipulation, CSS manipulation, HTML event methods, effects and animations, AJAX, utilities, … One of the key aspects of jQuery is the possibility to extend it ...

Read More »

ClojureScript Routing and Templating with Secretary and Enfocus

A good while ago I was looking for good ways to do client-side routing and templating in ClojureScript. I investigated using a bunch of JavaScript frameworks from ClojureScript, of which Angular probably gave the most promising results but still felt a bit dirty and heavy. I even implemented my own routing/templating mechanism based on Pedestal and goog.History, but something felt ...

Read More »

Communicating between views in Backbone

The backbone application that I am currently working on has a document section and a sidebar section.           To represent the above structure in Backbone, I came up with following views. ApplicationView – the container for the sub views. DocumentView – represents a current document being edited/displayed. SidebarView – shows relevant information for the document that ...

Read More »

Twitter Bootstrap Navbar as AngularJS Component

You all know Twitter Bootstrap, don’t you? It’s the awesome library to make your web application looks pretty good without spending many hours on CSS. We are using Bootstrap based design in our current project that also uses AngularJS and as we are planning to have many new pages, we decided that’s the earlier we introduce some components to our ...

Read More »

Pass JavaScript function via JSON. Pitfall and solution.

JSON is a lightweight data-interchange format. It is well readable and writable for humans and it is easy for machines to parse and generate. The most of JavaScript libraries, frameworks, plugins and whatever are configurable by options in JSON format. Sometimes you have to parse a JSON string (text) to get a real JavaScript object. For instance, sometimes you have ...

Read More »

Horizontal reuse in JavaScript and C#

In his article Horizontal Reuse: An Alternative to Inheritance Toby Inkster compares how to implement multiple inheritance or mixins in Java, Perl, PHP and Ruby. It’s a very interesting comparison of programming languages features and well worth the read. Toby writes: In class-based object-oriented programming, when there are classes that appear to share some functionality, this is often a time ...

Read More »