Monthly Archives: October 2015

Media Announcement

Media Announcement
” Pro-Tek Consulting is excited to announce the expansion of its services to Australia under the name “Pro-Tek Consulting Australia Pty Ltd”. Pro-Tek Consulting has already proven itself in Staffing, Web Design and Application Development services in USA and India. Pro-Tek’s monthly technical magazine “UI Street” is another successful offering to web development community in both the countries which has been receiving much of accolades from the web development community. Same services are planned to be offered in Australia. This Australian company is expected to be fully operational by the end of 2015. “

TOP 5 BEST APP MAKER TOOLS

Top 5 Best App Maker Tools

As the popularity of mobile dependence on applications grows day by day, more and more businesses are realizing the fact that its not just the web they need to have a presence on. They require their own specific applications catering to their customers’ requirements. The challenge however is that building an app isn’t everybody’s cup of tea. The costs involved are more often than not such that can only be afforded by significantly large businesses which leaves the small businesses and start­ups on the bench.

The silver lining to the cloud of expensive app building is that there are now several app making tools out in the market that can be used for building DIY apps. The benefit of resorting to these app building tools is that anybody can create apps of their own without having to learn how to code and other technicalities. This means that small business owners and those who cannot afford hiring a developer to create an app for them can now build apps of their own easily.

Best App Maker Tools

We decided to do a little research and come up with 5 of the best app making tools available. However, the user friendliness and efficiency of these apps could not have been tested adequately if used and scrutinized by the technically proficient. Therefore, we decided to get these apps tested by non-developers, asking them to
create a simple to-do list app using the following app building tools. Based on the reviews given by our testers and those of the online community, we discuss the following app making tools:

1. AppMakr

Primarily used for building native IOS and Android apps, App Makr is a free DIY app building platform that eliminates the need of coding in building apps. Any number of apps with unlimited updates can be built absolutely free. In addition to navigation control, monetization and tab viewing, push notifications, HTML5 functionality, live updates, branding, design customizations and high resolution photo galleries are some of the features.

If you’re building an app for the iphone, App Makr enables users to preview the app by publishing a test app that helps in assessing its look and feel before it can be launched in the app store. The app’s App Quality Index (AQI) which is a set of parameters that informs whether the built app would be rejected by Apple during the app review, is at all times displayed.

Is Appmark Safe

All apps created using the AppMakr are published under the developer’s account and brand, not under AppMakr’s name. AppMakr is a free platform with advertisements. Ad-less service is available too but for a cost of $1 a month which is inclusive of a native android app. A $9 per month plan allows creation of iphone, Android & HTML5 apps along with the ability of submitting the built apps to Apple’s App store and Google’s Play store.

Pros:

  • Any number of apps with unlimited updates can be built absolutely free.
  • Can preview the app by publishing a test app that helps in assessing its look and feel before it can be launched in the app store.
  • Awesome features and highly customizable. Based on the required needs we can have our app look exactly the way we want and can upload icons, headers, artwork, etc.

Cons:

  • We can’t view pages as they are published, instead you can preview by sending the app to yourself on your phone or by email.
  • Apple Publishing can be a little trickier and it takes more effort to build.

2. Bizness Apps

Bizness Apps

This tool is suitable for building apps for businesses spanning across industries. This tool has been designed bearing small businesses in mind. The tool enables users to build Android, iphone, ipad and mobile Webapps in addition to customizing them which is made possible by hundreds of customizable design templates that Bizness Apps offers.

Its features include push notifications, GPS, content sharing, social media, custom Email forms, food ordering, mobile reservations etc. It also enables users to preview their built apps before they are published.

Inter-app integration with other business apps is made possible which can be better understood with the example of importing contacts from the app to email marketing services such as MyEmma, MailChimp etc. In addition to the availability of a White Label Plan, the tool comes at a price of $24 a month for mobile websites and $49 a month for a native and mobile app.

Pros:

  • Makes mobile apps affordable and simple for small businesses.
  • Offers a user-friendly CMS that lets companies design and customize iPhone, iPad, Android and mobile Web apps.
  • Should pay a flat rate for unlimited Android apps and mobile websites.

Cons:

  • Limited options for E-commerce websites and it requires a proper app in place to handle all day to day activities.
  • Brand customization only available in custom pricing with White Label Reseller plan.

3. Canvas Business App

Canvas Business Apps

The Canvas Business App is a drag and drop app builder that aims at streamlining and organizing data collection and converting forms into mobile-ready digital formats. Functions such as workflow automation, confirmation or authorization via signature capturing, product tracking (via GPS) and purchase order calculations can be performed by apps built using the Canvas. In addition to accepting mobile payments, tracking inventory via barcode scanning and maintaining databases, Canvas offers something quite secure Cloud storage for its users. This feature is very enticing for users as it can be very useful in sharing of files and documents between the app users.This tool can be used for building iOS, Android and Windows Apps.

Pros:

  • Canvas Business Apps & Forms works on iOS, Android and Windows devices.
  • Makes apps easy, fast and affordable to create a mobile business application.
  • Integrates with cloud apps to replace paper forms everywhere.

Cons:

  • A 30-day free trial is available at the expiration of which, service can be continued for $13 a month per user.
  • Great with a few bugs – Resizing crashes the app sometimes.

4. Appy Pie

Appy Pie

A drag and drop platform which happens to be the fastest growing DIY app building tool feasible for building apps across all major platforms such as Android, Windows, iOS & Blackberry. Appy Pie enables automatic publishing of apps on their respective app stores including Appy Pie’s own marketplace.

Appy Pie’s functions include Social media and Blog integration, Push notifications, sharing capabilities, photo galleries, restaurant tools such as passbook coupons, Menu builder, OpenTable, GrubHub, GPS tracking for strategic location based marketing and One touch calling, QR code etc.

In addition to the aforementioned features, some features that make Appy Pie stand out from the rest of the tools are app analytics, real time updates and revisions, app monetization and custom coding. HTML5 apps can be designed using this tool for free.Appy Pie offers subscription plans for publishing an app starting at $7 a month for a single app. Every plan includes a free mobile website and all paid plans are inclusive of customer support.

Pros:

  • The interface provided by Appy Pie is user friendly and is easy to use.
  • Has its own market place which gives more visibility to your app.

Cons:

  • Few bugs in the interface, as it has not yet released its stable version.
  • Does not provide support for users to publish their apps on app store such as Google Play Store or Apple App Store.

5. Mobile Roadie

Mobile Rroadie

Used by renowned stalwarts like the NBA, NFL, NBCUniversal, TED, Verizon etc. Mobile Roadie is the most popular do-it-yourself app building tool available to businesses.

Mobile Roadie can be used for building apps laden with features such as geotargeted push notifications, location maps for filter engagement, mobile marketing tools, in-app activity rewards and points, chat options, news updates and a fan wall with threaded posts. In addition to these, features that facilitate photo gallery uploads via Flickr, Instagram, Twitpic, Facebook and video integration from You- Tube, Vimeo, Dailymotion etc. and audio imports from iTunes, SoundCloud etc. are also available. Using Mobile Roadie, Quick Response (QR) codes could be created which when scanned, unlock or link to other content.

Realizing the potential and the growing significance of analytics and data, Mobile Roadie offers businesses advanced analytics feature which reveals important customer activity data. Mobile Roadie’s services can be availed at $1499 per year.

Pros:

  • Offers great mobile marketing features to reach out wide range of audience.
  • Supports anytime content updates, geo-targeted marketing campaigns, user analytics, push notifications and more.

Cons:

  • Slightly expensive when compared to other app maker platforms.
  • Limited E-commerce support and no live chat option available.

AN OVERVIEW ON ANGULARJS 1.X to 2.X MIGRATION

An Overview on AngularJS 1.X to 2.X Migration

AngularJS, the open source library that everyone could contribute to will now have a sequel in the form of AngularJS 2.x. The lion’s share of contribution in the development of AngularJS is courtesy of Google employees which in a way makes AngularJS, a project of Google.

When AngularJS 2 was first rolled out with the information that 2.x wouldn’t be compatible with AngularJS 1.x, it created a huge havoc in theglobal developer community. Developers complained that this incompatibility would result in numerous hurdles that would be very difficult to deal with. Google, exercising their famed prudence and troubleshooting policy, announced that there would be a few intermediary releases (1.5x) that would pave the way to facilitate a hassle free roll out of the 2.x branch. This consolation however could not calm the nerves of developers.

  • The death of the controller, and a new emphasis on components
  • There’s no $scope object!
  • Dynamic Loading (lets developers add new directives or controllers on the fly)
  • Directives are 3 types. Component Directives, Decorator Directives (ex: ng‐show), Template Directives (ex: ng‐if)

benefits of Angular 2.x

Let’s have a look at what does Angular 2.x contain and what could be some of the steps to be taken to migrate from Angular 1.x to 2.x (that many devs are discussing).

Handling ANGULARJS 2.0:

AngularJS 1 application can be migrated to Angular 2 application over many commits ­ one component at a time. For this, we can utilize ng­upgrade (library) that “will automatically make all of the Angular 1 injectables available in Angular 2”. Mostly probably, Angular 2 will ship with ngUpgrade.js

Typical application upgrade process (at a high­level)

Here is an example of what an Angular 1 project upgrade to Angular 2 may look like (explains how to handle Scope, Directives, Services and the new “component” style)

1. Include the Angular 2 and ng­upgrade libraries with your existing application

  • Handling $scope.

The Big Question: Angular 2 doesn’t support 2­way bindings. How to handle this scenario?

Handling Angularjs 2.0

Directives. You can also write directives in a more future­minded way. First, you can remove almost all references to $scope

Angular 1 project upgrade to Angular 2

2. Pick a component which you would like to migrate

  • Edit an Angular 1 directive’s template to conform to Angular 2 syntax
  • Convert the directive’s controller/linking function into Angular 2 syntax/semantics
  • Use ng­upgrade to export the directive (now a Component) as an Angular 1 component (this is needed if you wish to call the new Angular 2 component from an Angular 1 template)

Angular2 component from an Angular 1 template

3. Pick a service which you would would like to migrate

  • Most services should require minimal to no change.
  • You can write services with the future in mind simply by creating an ES6 class to define the service, rather than a function
  • (optionally) re­export the service into Angular 1 using ng­upgrade if it’s still used by other parts of your Angular 1 code.

Angular 1 using ng­upgrade
4. Repeat doing steps in an order convenient for your application development
5. Once no more services/components need to be converted drop the top level Angular 1 bootstrap and replace with Angular 2 bootstrap.

If you are starting a brand new Application:

1. As the web is moving towards ES6, many web development leaders advise to start writing apps in ES6 (or TypeScript)
2. Stay away from $scope.
3. Start matching controllers with directives (by using ‘controllerAs’ and ‘bindToController’ properties in the directive)

BEST NODE.JS PERFORMANCE TIPS YOU CAN ADOPT

Best Node.js Performance Tips You Can Adopt

All of us know about the rapid adoption of JavaScript in the previous decade and major reason behind the popularity of JavaScript is the influence of Node.js. Node.js is the software platform used for building fast, robust and scalable network applications. It is mainly based on Google’s V8 Javascript search engine or the Chrome browser runtime. Node.js features an event­driven architecture and an I/O API that optimizes application scalability. One of the most important feature of Node.js is that it contains built­in library that acts as a web server and there is no need for web server such as IIS or Apache Web Server.

It is perceived that Javascript is the most used language on GitHub. Ryan Dahl, the creator of Node.js says , “ after over twenty years of stateless­web based on the stateless request-response paradigm, we finally have web applications with real time two way connections”. Need for adapting to the new technology of Node.js is actively discussed in global tech community including these prominent performance tips.

Going Asynchronous
Node.js is single threaded and there are lots of synchronous components that can lock up the entire application. It is practical to use an external library that has a blocking call and use of asynchronous API is the best possible solution. While choosing third party modules, it is to be ensured that external library does not revert to synchronous calls.

Keeping Code Small
Keeping code small and light is one of the most talked about node.js performance tips we can adopt. In the contemporary age of critical mobile application performance, it is important to keep Node.js code as compact as possible. Node.js is made compact for reducing latency as well as speeding things up.

Developers of node.js face the following questions during development stage

  • “Do we really need this module”?
  • “Why are we using this framework”?
  • “Is it worth the overhead”?

“Is there another way to optimize application performance by concatenating multiple JS files into one?”­ This statement can be explained with the help of an example. If a web app has five Javascript files, the browser will make five separate HTTP requests to fetch them and the best approach would definitely be to concatenate those five files into a single one.

DO NOT use Node.js for static assets:
Don’t use Nodejs to serve static assets like client JS, CSS, fonts or images. This is not good because Node doesn’t do this efficiently. Say we ask for a reasonably large image file and we’re serving it from a Express mount-point, this works when we’re developing it locally, because it’s just us using it. No load really. Use NGINX or CDN to deliver such static assets to reduce the load on your application server.

Don’t Store Too Much in Sessions
By default in a typical Express web app, the session data is stored in memory. Storing too much data in the session, it adds significant load to the server. Instead storing their id in the session will reduce the load on an app server rather than storing the entire object. So, either you can switch to different storages like MongoDB or Redis to store session data or go session­free with EXPRESS JS.

Here is an example of initializing the session.
app.use(express.session({ secret: “mysterious triangle” }));

Run in Parallel
Generally if we want to run multiple functions at a time, we need to wait for the previous function to execute. So to reduce latency we can go for parallel operations to run. To execute these calls in parallel, we can use Step.JS (A simple control-flow library for node.JS that makes parallel execution, serial execution, and error handling painless). This accepts any number of functions as arguments and runs as the callback to the next step.

Use Client Side Rendering When Possible
DO NOT render (or send) templates from Node JS side. Do it on client side using templating engines like Handlebar. Infact better do it using CDN so it can be cached. For dynamic content (like data), deliver it via JSON. So after the initial page load, the only data sent to the client is the dynamic JSON, which is maximally efficient. This approach dramatically reduces the CPU, IO, and load on Node.js.

Major companies using NODEJS and Why?
Global business giants like PayPal, Yahoo, EBay, Netflix, The Mail Online, and Walmart are betting big on Node.js. Tech giants are passionate of embracing power of Node.js for embedded devices and robotics. Node.js dominates the real time web application arena by using push technology that gives them a distinctive edge over server side web applications.

Chat applications are classic examples of lightweight, real time and data intensive applications of Node.js. It has been debated that two way communication and communication has been there since many years in the form of Java applets or Flash.

The promising technology of Node.js plays a pivotal role in the technology realm of any large business organization. What would be the possible reason? It is only because Node.js allows web developers to build one code base using one language. Performance, scalability, and short web development cycles help Node.js to find a place in the big league of technology innovations in 21st century.

“Node.js powers our web applications and has allowed our teams to move much faster in bringing their designs to life”­ PayPal

HOW TO CHOOSE CLOUD SERVICE?

How To Choose a Cloud Service?

It is an undeniable truth that Information Technology has transformed the way business is done. The enticing features inherent to the cloud concept such as storage and processing of data in third party data centres, access to various services at convenient prices and adequate sharing of necessary resources etc. have ensured its widespread acceptance and dependence across industries.

Choosing a cloud computing service can be a simple process if one knows what he wants, knows what to expect and understands business requirements. Primarily, there are three types of cloud computing service providers that provide unique cloud services:

Software as a service (SaaS)-

These are service providers that offer software as services. For example: Google Docs, Microsoft Office 365 etc. SAAS eliminates the need to install and run applications on individual computers. Though a few plugins might be required, SAAS applications can be run directly from a web browser without any downloads or installations.

Platform as a service (PaaS)-

PaaS is primarily a framework for developers to build, develop and customize applications. The development, functioning and testing of applications made using PAAS is hassle free, fast and economic.

Infrastructure as a service (IaaS)-

Iaas provides a virtual environment for access to the computing resource. The clients subscribing to this form of cloud computing are given access to virtualised components so that they could build their own IT platforms.

All these services are cost efficient and time saving as they save clients the trouble of setting everything right from servers to hardware up from scratch. This means that the memory required by a website to respond to a sudden increase in end users can be doubled within minutes, given the efficiency and scalability of these services. Most of these services can be availed on a pay-per-hour basis that is exclusive to each server, role or process.

Deployment Models: Which one to choose?

There are choices to make when it comes to adopting a cloud solution. The deployment of different models depends on the needs of each company. Some of the most effective cloud services available are as follows:

Windows Azure:

Windows Azure, which functions on the PaaS platform and supplies as well as manages the operating system, is a great choice to opt for if a specialized OS is not required in the building of applications. This means that one can devote complete attention to the building, deployment and the management of cloud applications without having to worry about OS updates and patches. Primarily, Azure offers three main roles:

  • Web Role: This is an Internet Information Services 7 Windows Azure supplied OS that enables the development of applications using web technologies such as ASP.NET, PHP and Node.JS
  • Worker Role: This Windows Azure supplied OS enables the hosting of applications such as Apache, Tomcat amongst several others and runs arbitrary code.
  • Virtual Machine Code: By uploading a Windows Server 2008 R2 (Enterprise or Standard) VHD image, the customer supplies the OS in this service. This role, which is presently in Beta, renders the customer responsible for updating the OS. Applications can be built on Windows Azure using any language, tool or framework.Microsoft offers a three month free trial of Azure, which is adequate time enough for professionals to become well-versed with it. The service can be bought on a pay-as-you-go basis or a six month commitment for customized, reduced pricing.

Amazon’s AWS:

Amazon Web Services (AWS Cloud) from Amazon that offers raw infrastructure to enable the functioning of any OS a customer’s applications might require. Despite offering OS control, Amazon Elastic lacks automated patching. Import of supported virtual machine images, creation of instances based on numerous Linux and Windows OSs is made possible. The service can be bought on an hourly rate basis, a one-time fee basis which entails a discounted hourly rate with a commitment of one or three years and on the basis of bidding. Following are best compute services in Amazon Web Services :

  • Auto Scaling:Auto Scaling helps you maintain application availability and allows you to
    scale your Amazon EC2 capacity up or down automatically according to conditions you define.
  • Amazon RDS: This makes easier to set up, operate, and scale a relational database in the cloud. It provides cost-efficient, resizeable capacity while managing time-consuming database management tasks, freeing up to focus on applications.
  • Elastic Load Balancer:This automatically distributes incoming application traffic across multiple Amazon EC2 instances in the cloud.

OpenStack:

OpenStack is a popular and rapidly developing cloud platform for the creation of IaaS (infrastructure as a service) platforms. It is jointly founded by Rackspace and NASA and is supported by other multiple established vendors including HP, IBM, Rackspace, Dell and Red Hat. It is a platform for creating and managing large groups of virtual private servers in cloud computing environment.

It controls large pools of compute storage and networking resources throughout a datacenter all managed through a dashboard that gives administrators control while empowering users to provision resources through a web interface. Many have deployed Openstack clouds to achieve control,business agility and cost savings without the licensing fees and terms of proprietary software. Its massive industry support, AWS compatibility, security, and powerful dashboard has made it highly competitive.

Rackspace Cloud Hosting:

Is a service that provides raw infrastructure with control over the OS. Rackspace, unlike other Iaas providers, does not allow the upload of a customer’s own virtual machines. Rather, either the Windows or the Linux versions, which are supported by the company must be chosen.

Rackspace offers numerous server sizes and charges a per hour fee for each server.
Rackspace, unlike others, does not let one stop the per-hour charges by halting instances. If one wants to be in possession of an idled server without being charged for it, the back-up must be done for the image (Which again incurs charges from Rackspace) and the server must be deleted from the account. The server can be added back anytime later.

The company presently does not offer a free trial. However, an account can be created for free to gain access to the administrative portal which gives a better understanding of the service’s functioning. Charges would only be incurred if any instances are created or other resources are used.

WEBRTC ON THE RISE

WEBRTC ON THE RISE
The Next Generation of Communication

Web RTC – An incredibly ground breaking technology that functions in symphony with other technologies and protocols.Voice and video chat between peers is the primary function of this protocol. The WebRTC is an initiative supported by industry stalwarts such as Google,Opera, Mozilla amongst others. Imagine if it was real easy to add video chat and peer-to-peer data sharing to your web application – without downloading any plugins! That’s the vision of WebRTC.

In order to be able to understand this concept and appreciate it better, let us start from the basics. Despite the potential for utilisation in several aspects, peer to peer communication remains the primary objective of WebRTC.

Let us consider an example, when we visit a website, we either click on a certain link or type in the web address. This triggers a request sent to the host server which combines all the scattered data/assets and then displays it in the form of a webpage. The simple logic here is that we send a request to a known and locatable server to get the response. This is the case of websites where requesting and receiving responses is involved. However, if I wish to have a video conference with a friend, the physics of the web change drastically. My friend’s computer is not a server so as to respond satisfactorily to requests. What is the solution then? The Session Initiation Protocol (SIP) comes to rescue and saves the day. This signalling protocol along with the aid of a Session Description Protocol (SDP) is utilized in WebRTC. The metadata relevant to multimedia is passed through the SDP protocol.

Through a series of interactions between the peers’ public facing IP addresses and signalling data channels, back end peer to peer negotiations and sessions are established. When two or more peers are connected to the same channel, communication and negotiation of session information is enabled.

To explain this further, the peer, that initiates, actually sends an offer with the aid of SIP and
SDP. The peer then awaits a response from any receivers that are connected to the channel. Once the answer is received, a complex technical procedure follows which results in the complete establishment and activation of the network socket session between peers. After the creation of data channel endpoints and local data streams, multimedia data is finally transmitted between the peers with the aid of the relevant communications technology used.

What’s the need for WebRTC?

WebRTC is an open source technology that provides Real-Time Communications (RTC)
capabilities to best serve real-time, plugin-free video, audio and data communication. There are many reasons why the need is real:

  • Though many use RTC already, there is a need to downloads, native apps or plugins such as Skype, Facebook (which uses Skype) and Google Hangouts (which use the Google Talk plugin).
  • Downloading, installing and updating plugins is usually more complex, and many people get confused to deploy, debug, troubleshoot, test and maintain.
  • Also, integration with other applications via simple, standardized web APIs or browsers is difficult and sometimes may require purchasing license.

All these reasons are a considerable problems to the goal of achieving real-time communication. Hence, WebRTC is the technology that was in place to make these all possible. Open source, free, standardized, built into web browsers and more efficient than existing technologies is what makes WebRTC prominent to choose.

How WebRTC is better than others?

The quality of WebRTC videos is clearly better than those of Flash. Enabling more effortless
and near flawless virtual conversations, WebRTC offers significant improvements in latency. By eliminating the reliance on downloading proprietary softwares and creating accounts, WebRTC solves the prevalent problem of real time communications incompatibilities. By facilitating browser-to-browser communication, WebRTC capitalizes on the trend of a browser behaving as an application.

Businesses using WebRTC:

Businesses that utilize the WebRTC are providing personalized solutions to customers across the world by enabling direct hassle-free video conferences between clients and service providers seamlessly. WebRTC is also foraying into the field of robotics where a robot’s “eye”, the camera, is integrated with this technology which streams live video to users effectively. Fluke, a mobile field service app leveraging the ShareLive video call feature with the aid of WebRTC, enables teams across different locations to stay on the same page so that what is seen by one is also seen by all. Chegg Tutors,are another in a line of WebRTC beneficiaries that are leveraging the concept to offer online expert tutorials to those who need help in a certain area of academics. By enabling video conferencing, file sharing and file uploading, Chegg Tutors has utilized the WebRTC and witnessed its manifold benefits.

These are only a few names that have been mentioned here. There are many more businesses that are resorting to WebRTC due to the ubiquitous positive effects. It can therefore be said with the utmost certainty that WebRTC is not just on the rise but on the path of transforming real time communications.

WHICH TOOLS COULD BE USED TO DEBUG NODE.JS APPLICATIONS?

Which tools could be used to debug Node.js applications?

Many times when a complex situation arises. A good debugging tool will make our lives easy. Here some of the tools that you may consider to “npm install”

  1. node­inspector
  2. Joyent
  3. Node Webkit Agent
  4. NodeJS Plugin for WebStrom
  5. Cloud9 IDE (has built in debugger for Node)

 
 

WHAT ARE THE ADVANTAGES AND DISADVANTAGES OF “USE STRICT” KEYWORD IN JS?

What are advantages and disadvantages of “Use Strict” keyword in JS?

“Use Strict” is a new feature introduced in ECMAScript 5. The purpose of “use strict” is to indicate that the code should be executed in “strict mode”. For example, with strict mode, you cannot use undeclared variables.

“use strict”;
display();
function display() {
info = 30; // This will also cause an error
Strict mode helps out in the following ways:
• It catches some common coding bloopers, throwing exceptions.
• It prevents, or throws errors, when relatively “unsafe” actions are taken (such as gaining access to the global object).
• It disables features that are confusing or poorly thought out.
Browser support:
• Internet Explorer from version 10.
• Firefox from version 4.
• Chrome from version 13.
• Safari from version 5.1.
• Opera from version 12.

HOW DO JAVASCRIPT CLOSURES WORK?

How do JavaScript closures work?

Closure is related to Scope. Let’s assume that we have a function named ‘Outer’. Inside this function, let’s create a ‘inner’ function. Looks something like below:

function outer(){
function inner(){
}}

Let’s create a variable in outer function. Now, the inner function will have access to this outer function variable. The inner function is now a closure.

function outer(){
var info = “Hello”;
function inner(){
console.log(info); //Prints Hello – inner() fn has access to info var
}}

So, to put it in as a text book definition, A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain.The inner function shall have access to three different scope vars:

• It’s own variables
• Outer function variables
• Global variables
var greet = “Welcome”;
function outer(){
var info = “Hello”;
function inner(){
var name = “James”;
console.log(info); //Prints Hello – inner() fn has access to info var
console.log(name); //Prints James
console.log(greet); //Prints Welcome
}
}
P.S: The inner function shall have access to the outer function parameters as well
Dispelling the Myths of closure:
Myth 1. Closures are created only after an inner function has been returned
Myth 2. Closures only apply to inner functions