Jasmine is a framework which is used for testing node.js code or javascript code. Installation To install the latest official version, use NPM: [js]npm install jasmine-node -g[/js] Write the specifications for your code in *.js and *.coffee files in the spec/ directory Execution After installing the npm package, you can...
MongoDB provides several ways of computing the average value of a group in a collection. One of the simplest ways of determining average is using the method db.collection.group(). The method db.collection.group() bunches the documents of a collection on the basis of the keys mentioned and executes aggregation functions on them. This...
Most people using JavaScript misunderstand the difference between ‘null’ and ‘undefined’. An unclear distinction between these two entities can lead to grave issues when using ‘null’ and ‘undefined’ in test cases. A variable is said to be ‘undefined’ if it has been declared, but no value has been given to it....
We are assuming that you have installed js2 in your system, in case if you have not installed js2, first install js2. First of all create a InheritanceTest.js2 file in scr directory with the content given below: [js] class Person { // Parent class var firstName; var lastName; function initialize(firstName, lastName)...
We are assuming that you have installed node.js in your system, in case if you have not installed node.js, first install node.js. To install js2 run the command given below: [bash] npm install js2 [/bash] Let’s create a simple Hello World project, but first let’s create a project directory structure: [bash] mkdir...
Many people get confused with these two functions in JavaScript, most of the time people think that we can pass an object in apply() and access it with this which is not possible with the call() method. But that is not the case, let's see an example which will make it more clear. Using call() method: [js] (function sum(a,b,c) { ...
There are four patterns of invocation in JavaScript: 1. The method invocation pattern. 2. The function invocation pattern. 3. The constructor invocation pattern. 4. The apply invocation pattern. 1. The Method Invocation Pattern: When a function is stored as a property of an object, we call it a method. When a method is invoked,...
I keep on experimenting on new things. So this time I thought of experimenting on something which I can use in my daily routine. I regularly visit a deals webpage. So, I thought of making an android mobile app for my android device that can track the deals webpage and notifies me whenever a new deal is added. The deals website does...
Recently, I learnt something very new e.g. Knockout.js. It is quite a advanced form of javascript. It just simplifies the structure of the javascipt in your application. It basically follows MVVM pattern(Model View View Model). It is quite fast and easy to use as comparison to jquery. Some of it's key features are :- 1. Declarative...
Hi, Currying is a very simple and useful concept in JavaScript. Here we can set the context of the function to any object or variable. So let us study this concept using the practical examples and code as follows: [js] //Let us first create a function "curry" function curry(thisObject, func){ return...
Hi, When working with JavaScript, we might sometimes require to run some regEx on a string and replace its matches logically. This can be easily done using the String:replace() method. Lets Take an example to understand the concept: Suppose we want to write a function which converts the normal string to CamelCase...
AngularJS, Front End Development
In all previous blogs on AngularJS, we used hard coded data. Now, its the time to get more dynamic and play with the data fetched from the server. For this, we will use AngularJS dependency injection which injects various services into the controller. To use a service is even more simpler. We just declare the name of the service as an...