A platform where knowledge is in open air.

2015

07:01:00
Eset Nod32 Apk pro Protect your Android smartphone or tablet with Mobile Security & Antivirus from ESET. Proactive Anti-Theft will alert you before you even realize your device might be missing. Anti-Phishing shields your personal information online.


Fixed: Small bug fixes and optimization
Changed: Change of Permanent icon notification (for Android 5)
Changed: New options in Anti-theft settings
Key For Nod 32 Till : 11/29/2016








Download Link :- Link | Alternative Link | Alternative Link 2
Serial Keys :- Link

Comment here for your feedback.

07:01:00
Kaspersky Antivirus/Internet Security/Total Security 2016 16.0.0.614 en-US

(Released: Dec, 2015)

Language: English


Kaspersky 2016 :
is an antivirus protection software,
that effectivelly defenses your PC from malware.
Kaspersky Internet Security 2016 keeps your PC safe from all viruses
and Internet threats. It is a full security solution that rigorously
protects your files and your identity from cyber criminals and the
latest malware attacks. Kaspersky Total Security 2016 Multi-Device
(replaces Kaspersky PURE) delivers the ultimate security for computers
and mobile devices. It protects your privacy, money, identity, photos,
files and family against Internet threats, cybercrime and malware –
so no aspect of your digital security is left to chance.

Features:
Near-perfect protection
Fullest complement of useful extras
Hardened, sandboxed browser for shopping and banking
Unique webcam protection
Windows backup and recovery software.
Anti-malware
Safety checks
Automatic Exploit Prevention
FREE, automatic updates
Safer networking
System Watcher and Anti-Blocker
Application Control
Network Attack Blocker
Anti-Banner
Anti-Spam
Anti-Phishing
Webcam Protection
Secure Keyboard

How The Patch Work 100%
Restart Computer (Safemode)
Run Trial Resetter Patch
Now Restart Computer Normal Mode.

Program Version: 12.16.15
Type of medicine: Keys and serials

System requirements:
A Windows 2000 / XP / Vista / 7/8 / 8.1
ESET NOD32, Kaspersky, Avast, Dr.Web, Avira

Description:
Current version of the collection of keys for popular antivirus: ESET NOD32, Kaspersky, Avast, Avira.



If any serial not working, comments here. I will update immediately.
Link is above:


ESET ANTI-VIRUS KEYS
Avast Pro Antivirus | Alternative link 1 | Alternative Link 2 | Alternative Link 3
Avast Premier | Alternative link 1Alternative Link 2 | Alternative Link 3
Avast Internet Security | Alternative link 1 | Alternative link 2 | Alternative link 3
Avira Serial Keys 

06:12:00
MX Player - The best way to enjoy your movies.

a) HARDWARE ACCELERATION - Hardware acceleration can be applied to more videos with the help of new H/W decoder.
b) MULTI-CORE DECODING - MX Player is the first Android video player which supports multi-core decoding. Test result proved that dual-core device’s performance is up to 70% better than single-core devices.
c) PINCH TO ZOOM, ZOOM AND PAN - Easily zoom in and out by pinching and swiping across the screen. Zoom and Pan is also available by option.
d) SUBTITLE GESTURES - Scroll forward/backward to move to next/previous text, Up/down to move text up and down, Zoom in/out to change text size.
e) KIDS LOCK - Keep your kids entertained without having to worry that they can make calls or touch other apps. (plugin required)

Subtitle formats:
- DVD, DVB, SSA/ASS Subtitle tracks.
- SubStation Alpha(.ssa/.ass) with full styling.
- SAMI(.smi) with ruby tag support.
- SubRip(.srt)
- MicroDVD(.sub)
- VobSub(.sub/.idx)
- SubViewer2.0(.sub)
- MPL2(.mpl)
- PowerDivX(.psb)
- TMPlayer(.txt)
- Teletext
- PJS(.pjs)
- WebVTT(.vtt)
******
WHAT'S NEW

Known issues:
Android 6 x86 is not yet supported.
HW+ decoder may be instable on some devices.
Tegra 3 is not yet supported.

Changes:
Supports playback speed control. Speed can be changed on [Menu > Play > Speed] or by swiping up/down with two fingers. This feature is not available with HW decoder before Android 6.
SSA subtitle rendering can be improved optionally on [Menu > Subtitle > Settings > Text]. This feature only works with SW decoder as of now.
Improved network buffering.
De-interlacing algorithm can be selected between yadif and w3fdif. This feature only works with SW decoder as of now.
List screen floating button can be removed optionally on [Settings > List > Floating button].
Remembers selections/options from previous playback even if starting over playback. This behavior can be changed on [Settings > Player > Remember selection].
Fixed some issues on Android 6.
No longer supports Android 2.x, 3.0/3.1 and ARMv5, ARMv6, MIPS CPUs.

This app has no advertisements

Note:
Patched version, no Lucky Patcher or Google Play MOD needed!
Please remove all previous version and codec at first!!!
* Make a backup of your current version's data/setting (if necessary)
** Restore your backup data/setting (if necessary)

*1.8.1 is intermediate version of final 1.8 with fixes for Android 6. If you are using Android < 6 and want to try 1.8.1, please try beta version.
** Note for Android 6 Tegra3, x86 users: Tegra3 and x86 codecs are not yet available. Please use 1.7.x for a while.

Download Link (v1.8.1): Link 1 | Alternative Link 2 |  Alternative Link 3
Download Link (v1.8.2): Link 1 | Alternative Link 2 |  Alternative Link 3

Ola Cabs v3.4.11 Apk Is Here + [With Free Ride Voucher]! [Latest] 


Ola Cabs

Ola cabs app offers City Taxi rides on a point to point basis across several cities in India [India Only Doesn’t serves Abroad]. We are changing the way you move around in your city with a range of cab options to choose from – Sedan, Mini and Prime, it even offers auto and taxis on its portal and what more now we can even order food from the app!! Isn’t it great to order food for free(payment via ola money). Now YOU CAN EVEN BOOK YOUR CAB WITHOUT MOBILE/TAB!.

Free Ride:-

    Install the given apk.
    Choose the option to sign up.
    Fill all details and enter Use referral code “N0ZVK0“   Without Braces and they are zeroes [Entering incorrect code may not provide you with free ride.]
    Continue with process and sign-up, Referral code will provide you with a Ola coupon [Between Rs 100-Rs 500, Randomly]
    While booking your Ola Ride use coupon code- APP100 -Rs 100
    You will get a discount of Rs 100 for coupon code.
    On your 2nd ride use the coupon credited randomly to your account and get minimum discount of Rs100.
    Coupon APP100 is Applicable on First ride Only! But Ola Coupon could be used on other ride too (*_*).Enjoy your free ride but make sure that you haven’t exceeded the discount as you have to pay extra!!

Please visit their Terms and conditions page before ordering/Riding

Code- N0ZVK0

Screenshots



Link to Download Ola -

Ola cabs - Book taxi in India  Mirror 1  Mirror 2  Mirror 2  Mirror 3


IRCTC

Now a days we faced a serious problem when we try to buy a tatkal / emergency IRCTC Train tickets. But the problem is over. You can also buy a ticket from your home within a minutes.

Needed:

1. Computer
2. Internet Connection

What is Magic Autofill ?
Let me discuss about Magic Autofill.
Magic Autofill is a one kind of browser extension (Chrome, Firefox, Opera etc.). It's a bookmark dragging tool.


Before start your IRCTC reservation you have to fill your needed ticket information. After that you have to bookmark the Magic Autofill button on your browser bookmark bar.
When you login in your IRCTC booking page that time click on Magic Autofill button, automatically fill that details what ever enter on Magic Autofill form.

This is how Magic Autofill works. The bookmarking script is created by Amit Aggarwal of Digital Inspiration.

Magic Autofill

This is when Magic Autofill comes to act. You can simply fill your train reservation form in advance and save the data in Magic Autofill so that when the real-book time comes at IRCTC, you can simply click on Magic Autofill button and it will autofill your train reservation form. You don’t need to fill your train reservation form again at IRCTC. Move forward, make payment and you win the train emergency ticket.

After click Magic Autofill

How To Download Magic Autofill?

To get Magic Autofill for IRCTC, visit ctrlq.org/irctc/. Click the reservation form button and you’ll get a dummy train reservation form. Just fill at with the exact details you would fill at tatkal reservation form. When you’re done, verify all your entries and click “I’m Feeling Lucky” button.
Now, Magic Autofill button appears. Drag this Magic Autofill button at your Bookmark toolbar of Chrome (or any other browser). And, go ahead to win IRCTC tatkal reservation tickets with the help of IRCTC.
This video is showing working of Magic Autofill for IRCTC


05:52:00

The Samsung Electric Industries founded in 1969 at Suwon, South Korea. They release their first Android smartphone in 2009, and they also published first Android  tablet in 2010. The company is among the biggest players in the smartphone market in the world. It has recently developed smartphones running Tizen OS, as an alternative to its Android-based smartphones. they recently lunched Samsung Galaxy S6 Edge worldwide.

Samsung Galaxy S6 Edge smartphone was launched in March 2015. The phone comes with a 5.10-inch touchsceen display with a resolution of 1440 pixels by 2560 pixels at a PPI of 577 pixels per inch.
The Samsung Galaxy S6 Edge is powered by 1.5GHz octa-core Samsung Exynos 7420 processor and it comes with 3GB of RAM. The phone packs 32GB of internal storage cannot be expanded. As far as the cameras are concerned, the Samsung Galaxy S6 Edge packs a 16-megapixel primary camera on the rear and a 5-megapixel front shooter for selfies.
The Samsung Galaxy S6 Edge runs Android 5.0 and is powered by a 2600mAh non removable battery. It measures 142.10 x 70.10 x 7.00 (height x width x thickness) and weighs 132.00 grams.
The Samsung Galaxy S6 Edge is a single SIM (GSM) smartphone that accepts a Nano-SIM. Connectivity options include Wi-Fi, GPS, Bluetooth, NFC, 4G (with support for Band 40 used by some LTE networks in India). Sensors on the phone include Proximity sensor, Ambient light sensor, Accelerometer, and Gyroscope. 

05:45:00
Ubuntu is a Debian-based Linux operating system and distribution, with Unity as its default desktop environment for personal computers including smartphones in later versions. They released their latest version 15.10 (Wily Werewolf), they also announce that next version will be at 2016-04-21 (Xenial Xerus) 16.10 LTS.

Lest see what is the new version in 15.10 version -

1. Linux kernel 4.2

Ubuntu 15.10 ships with linux kernel 4.2. This introduces lots of changes, like support for the new AMD GPU driver, NCQ TRIM handling, queue spinlocks, F2FS per-file encryption and lots of new and updated drivers.

2. Unity 7.3.2

Unity as the main desktop of ubuntu 15.10 has been updated to version 7.3.2. it comes with bug fixes, polish and small usability improvements. The following we can mention the features of Unity 7.3.2:

Allows drag and drop apps from the Dash to the desktop to create shortcuts
Page up/down keyboard navigation works as scroll in the Dash
Dash title & BFB tooltip is updated based on your privacy settings
Session exit buttons now have a click effect
Fix to prevent ‘shutdown’ of computer when screen is locked
Active app icons now show unfolded when launcher accordion triggered
Fix for full screen menubar
Fixes issues with ‘show desktop’ that caused window decoration for two windows of same app to vanish
Dash: Non-expandable category headers skipped in keyboard navigation
Dash: Non-expandable category headers are no longer highlighted on mouse over
Dash: screenreader and KeyNav fixes
New setting to control the show-now delay (when pressing Alt key)
Logic tweak to stop adjacent menu opening when moving from an indicator icon to its menu

3. GNOME 3.16 stack

Another important changes for this release, the most of the packages from the GNOME stack updated to version 3.16.x. This is a good thing since these packages do come with lots of improvements.Unfortunately, the nautilus file manager for Ubuntu 15.10 is still in version 3.14 and Gedit text editor file still dating from 3.10.

4. Introduce GNOME Overlay Scrollbars

In Ubuntu 15.10, Ubuntu developers have decided to implement the GNOME Overlay scrollbars, it replacement of Unity’s overlay scrollbars for GTK3 applications. That’s no different than before, but it does serve as a stark and regular reminder of how much easier it is to use scrollbars that are always present in a predicable spot and wider than the pinpoint tip of a mouse cursor.

5. Ubuntu Make

Ubuntu Make, a command-line utility that allows you to download the latest version of popular developer tools easier on Ubuntu, now supports even more platforms, frameworks and services, including a full Android development environment.

6. Persistent Network Interface Names

Ubuntu developer also introduces stateless persistent network interface names in Ubuntu 15.10. This means that naming the network interfaces like eth0 or eth1 will be a thing of the past and that new more comprehensive names will be used. Also, the names will remain valid even after a restart or if the hardware is removed.

7. Steam Controller Support

In this release, Ubuntu Developer also add support for the Steam Controller in Ubuntu 15.10. For now, the updated Steam package seems to be available only for Ubuntu 15.10, but it’s possible that the patch will be backported to other supported distributions. This means that Ubuntu 15.10 users will be able to plug the new controller, open Steam, and just play without having to read and apply any kind of advice from tutorials.

8. New Default Wallpaper

Ubuntu 15.10 bring a new default wallpaper, the wallpaper desaign concept adopted from origami and it called suru. A new set of community sourced wallpapers are also included.

9. Core Applications Updates

Ubuntu 15.10 updates the core applications. among them:

Firefox 41
Chromium 45
LibreOffice 5.0.2
Totem (aka ‘Videos’) 3.16
Nautilus (aka ‘Files’) 3.14.2
Rhythmbox 3.2.1
GNOME Terminal 3.16
Eye of GNOME 3.16
Empathy 3.12.10
Shotwell 0.22

Download Ubuntu 15.10 Final Release

The image of Ubuntu 15.10 ready to download and install. it available in 64-bit and 32-bit, the both can download from the official ISO downloads page by hitting the link below

http://releases.ubuntu.com/15.10/ (Ubuntu Desktop, Server, and Snappy Core)
http://cdimage.ubuntu.com/ubuntu/releases/15.10/release/ (Less Popular Ubuntu Images)
http://cloud-images.ubuntu.com/releases/15.10/release/ (Ubuntu Cloud Server)
http://cdimage.ubuntu.com/netboot/15.10/ (Ubuntu Netboot)
http://cdimage.ubuntu.com/kubuntu/releases/15.10/release/ (Kubuntu)
http://cdimage.ubuntu.com/lubuntu/releases/15.10/release/ (Lubuntu)
http://cdimage.ubuntu.com/ubuntustudio/releases/15.10/release/ (Ubuntu Studio)
http://cdimage.ubuntu.com/ubuntu-gnome/releases/15.10/release/ (Ubuntu GNOME)
http://cdimage.ubuntu.com/ubuntukylin/releases/15.10/release/ (Ubuntu Kylin)
http://cdimage.ubuntu.com/ubuntu-mate/releases/15.10/release/ (Ubuntu MATE)
http://cdimage.ubuntu.com/xubuntu/releases/15.10/release/ (Xubuntu)

Upgrading from Ubuntu 15.04

To upgrade on a desktop system:

Open the "Software & Updates" Setting in System Settings.
Select the 3rd Tab called "Updates".
Set the "Notify me of a new Ubuntu version" dropdown menu to "For any new version".
Press Alt+F2 and type in "update-manager" (without the quotes) into the command box.
Update Manager should open up and tell you: New distribution release '15.10' is available.
Click Upgrade and follow the on-screen instructions.
To upgrade on a server system:

Install the update-manager-core package if it is not already installed.
Make sure the /etc/update-manager/release-upgrades is set to normal.
Launch the upgrade tool with the command sudo do-release-upgrade.
Follow the on-screen instructions.
Note that the server upgrade will use GNU screen and automatically re-attach in case of dropped connection problems.

There are no offline upgrade options for Ubuntu Desktop and Ubuntu Server. Please ensure you have network connectivity to one of the official mirrors or to a locally accessible mirror and follow the instructions above.

Source : ubuntu.com

05:22:00
Android, One of the popular OS used in Mobile and Tablet. You can also use android in your PC using Virtual Machine. Google takeover Android.Inc in 2005 and unveiled in 2007. Android is an operating system based on the Linux kernel with a user interface based on direct manipulation, designed primarily for touchscreen mobile devices such as smart phones and tablet computers.

The Android OS written in   C (core), C++, Java (UI).

Version            Code name                    Release date   
7.0                 Oreo                             August 21, 2017
6.0                 Marshmallow                  October 5, 2015
5.1.x               Lollipop                        March 9, 2015
5.0–5.0.2                                            November 3, 2014
4.4–4.4.4        KitKat                            October 31, 2013
4.3.x              Jelly Bean                      July 24, 2013
4.2.x                                                  November 13, 2012
4.1.x                                                  July 9, 2012
4.0.3–4.0.4     Ice Cream Sandwich        December 16, 2011
2.3.3–2.3.7     Gingerbread                   February 9, 2011
2.2–2.2.3       Froyo                             May 20, 2010

04:55:00
A UNIX admin has literally thousands of commands at his/her beck and call. However, with the whopping number also comes the need to be doubly sure of what each command stands for. While it takes practice to get used to them, we are here to make your life easier by compiling a list of 15 Unix commands and their key functions.





1.alias

-substitute a more familiar name in place of a long string.

2.awk

-search for patterns in a file and process them.

3.cd

-sets the working directory of a process.

4.chown

-changes file ownership.

5.chmod

-changes file permission.

6.cp

-copy files.

7.cpio

-copy and move around files and directories.

8.df

-reports filesystem disk space usage.

9.env

-displays information about your current environment.

10.echo

-echoes a string variable to standard output.

11.ftp

-copies files back and forth on different host machines.

12.grep

-searches one or more files for a given character string or pattern.

13.id

-prints out real and effective UIDs and GIDs.

14.head

-outputs the first part of a file.

15.ssh

-Used for secure network connections and tunneling of TCP services. 

04:44:00
As you know, JavaScript is the number one programming language in the world, the language of the web, of mobile hybrid apps (like PhoneGap or Appcelerator), of the server side (like NodeJS or Wakanda) and has many other implementations. It’s also the starting point for many new developers to the world of programming, as it can be used to display a simple alert in the web browser but also to control a robot (using nodebot, or nodruino). The developers who master JavaScript and write organized and performant code have become the most sought after in the job market.
In this article, I’ll share a set of JavaScript tips, tricks and best practices that should be known by all JavaScript developers regardless of their browser/engine or the SSJS (Server Side JavaScript) interpreter.

Note that the code snippets in this article have been tested in the latest Google Chrome version 30, which uses the V8 JavaScript Engine (V8 3.20.17.15).
1 – Don’t forget var keyword when assigning a variable’s value for the first time.
Assignment to an undeclared variable automatically results in a global variable being created. Avoid global variables.
2 – use === instead of ==
The == (or !=) operator performs an automatic type conversion if needed. The === (or!==) operator will not perform any conversion. It compares the value and the type, which could be considered faster than ==.
[10] === 10    // is false
[10]  == 10    // is true
'10' == 10     // is true
'10' === 10    // is false
 []   == 0     // is true
 [] ===  0     // is false
 '' == false   // is true but true == "a" is false
 '' ===   false // is false
3 – undefinednull, 0, falseNaN'' (empty string) are all falsy.
4 – Use Semicolons for line termination
The use of semi-colons for line termination is a good practice. You won’t be warned if you forget it, because in most cases it will be inserted by the JavaScript parser. For more details about why you should use semi-colons, take a look to this artice: http://davidwalsh.name/javascript-semicolons.
5 – Create an object constructor
function Person(firstName, lastName){
    this.firstName =  firstName;
    this.lastName = lastName;       

var Saad = new Person("Saad", "Mousliki");
6 – Be careful when using typeofinstanceof and constructor.
·         typeof : a JavaScript unary operator used to  return a string that represents the primitive type of a variable,  don’t forget that typeof null will return “object”, and for the majority of object types (Array, Date, and others) will return also “object”.
·         constructor : is a property of the internal prototype property, which could be overridden by code.
·         instanceof : is another JavaScript operator that check in all the prototypes chain the constructor it returns true if it’s found and false if not.
var arr = ["a", "b", "c"];
typeof arr;   // return "object"
arr  instanceof Array // true
arr.constructor();  //[]
7 – Create a Self-calling Function
This is often called a Self-Invoked Anonymous Function or Immediately Invoked Function Expression (IIFE). It is a function that executes automatically when you create it, and has the following form:
(function(){
    // some private code that will be executed automatically
})(); 
(function(a,b){
    var result = a+b;
    return result;
})(10,20)
8 – Get a random item from an array
var items = [12, 548 , 'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' , 2145 , 119];

var  randomItem = items[Math.floor(Math.random() * items.length)];
9 – Get a random number in a specific range
This code snippet can be useful when trying to generate fake data for testing purposes, such as a salary between min and max.
var x = Math.floor(Math.random() * (max - min + 1)) + min;
10 – Generate an array of numbers with numbers from 0 to max
var numbersArray = [] , max = 100;

for( var i=1; numbersArray.push(i++) < max;);  // numbers = [1,2,3 ... 100]
11 – Generate a random set of alphanumeric characters
function generateRandomAlphaNum(len) {
    var rdmString = "";
    for( ; rdmString.length < len; rdmString  += Math.random().toString(36).substr(2));
    return  rdmString.substr(0, len);

}
12 – Shuffle an array of numbers
var numbers = [5, 458 , 120 , -215 , 228 , 400 , 122205, -85411];
numbers = numbers.sort(function(){ return Math.random() - 0.5});
/* the array numbers will be equal for example to [120, 5, 228, -215, 400, 458, -85411, 122205]  */
A better option could be to implement a random sort order by code (e.g. : Fisher-Yates shuffle), than using the native sort JavaScript function. For more details take a look to this discussion.
13 – A string trim function
The classic trim function of Java, C#, PHP and many other language that remove whitespace from a string doesn’t exist in JavaScript, so we could add it to the Stringobject.
String.prototype.trim = function(){return this.replace(/^\s+|\s+$/g, "");}; 
A native implementation of the trim() function is available in the recent JavaScript engines.
14 – Append an array to another array
var array1 = [12 , "foo" , {name "Joe"} , -2458];

var array2 = ["Doe" , 555 , 100];
Array.prototype.push.apply(array1, array2);
/* array1 will be equal to  [12 , "foo" , {name "Joe"} , -2458 , "Doe" , 555 , 100] */
15 – Transform the arguments object into an array
var argArray = Array.prototype.slice.call(arguments);
16 – Verify that a given argument is a number
function isNumber(n){
    return !isNaN(parseFloat(n)) && isFinite(n);
}
17 – Verify that a given argument is an array
function isArray(obj){
    return Object.prototype.toString.call(obj) === '[object Array]' ;
}
Note that if the toString() method is overridden, you will not get the expected result using this trick.
Or use…
Array.isArray(obj); // its a new Array method
You could also use instanceof if you are not working with multiple frames. However, if you have many contexts, you will get a wrong result.
var myFrame = document.createElement('iframe');
document.body.appendChild(myFrame);

var myArray = window.frames[window.frames.length-1].Array;
var arr = new myArray(a,b,10); // [a,b,10] 

// instanceof will not work correctly, myArray loses his constructor
// constructor is not shared between frames
arr instanceof Array; // false
18 – Get the max or the min in an array of numbers
var  numbers = [5, 458 , 120 , -215 , 228 , 400 , 122205, -85411];
var maxInNumbers = Math.max.apply(Math, numbers);
var minInNumbers = Math.min.apply(Math, numbers);
19 – Empty an array
var myArray = [12 , 222 , 1000 ]; 
myArray.length = 0; // myArray will be equal to [].
20 – Don’t use delete to remove an item from array
Use splice instead of using delete to delete an item from an array. Using delete replaces the item with undefined instead of the removing it from the array.
Instead of…
var items = [12, 548 ,'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' ,2154 , 119 ];
items.length; // return 11
delete items[3]; // return true
items.length; // return 11
/* items will be equal to [12, 548, "a", undefined × 1, 5478, "foo", 8852, undefined × 1, "Doe", 2154,       119]   */
Use…
var items = [12, 548 ,'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' ,2154 , 119 ];
items.length; // return 11
items.splice(3,1) ;
items.length; // return 10
/* items will be equal to [12, 548, "a", 5478, "foo", 8852, undefined × 1, "Doe", 2154,       119]   */
The delete method should be used to delete an object property.
21 – Truncate an array using length
Like the previous example of emptying an array, we truncate it using the length property.
var myArray = [12 , 222 , 1000 , 124 , 98 , 10 ]; 
myArray.length = 4; // myArray will be equal to [12 , 222 , 1000 , 124].
As a bonus, if you set the array length to a higher value, the length will be changed and new items will be added with undefined as a value. The array length is not a read only property.
myArray.length = 10; // the new array length is 10
myArray[myArray.length - 1] ; // undefined
22 – Use logical AND/ OR for conditions
var foo = 10; 
foo == 10 && doSomething(); // is the same thing as if (foo == 10) doSomething();
foo == 5 || doSomething(); // is the same thing as if (foo != 5) doSomething();
The logical OR could also be used to set a default value for function argument.
function doSomething(arg1){
    arg1 = arg1 || 10; // arg1 will have 10 as a default value if it’s not already set
}
23 – Use the map() function method to loop through an array’s items
var squares = [1,2,3,4].map(function (val) { 
    return val * val; 
});
// squares will be equal to [1, 4, 9, 16]
24 – Rounding number to N decimal place
var num =2.443242342;
num = num.toFixed(4);  // num will be equal to 2.4432
NOTE : the toFixed() function returns a string and not a number.
25 – Floating point problems
0.1 + 0.2 === 0.3 // is false
9007199254740992 + 1 // is equal to 9007199254740992 
9007199254740992 + 2 // is equal to 9007199254740994
Why does this happen? 0.1 +0.2 is equal to 0.30000000000000004. What you need to know is that all JavaScript numbers are floating points represented internally in 64 bit binary according to the IEEE 754 standard. For more explanation, take a look to this blog post.
You can use toFixed() and toPrecision() to resolve this problem.
26 – Check the properties of an object when using a for-in loop
This code snippet could be useful in order to avoid iterating through the properties from the object’s prototype.
for (var name in object) { 
    if (object.hasOwnProperty(name)) {
        // do something with name                   
    } 
}
27 – Comma operator
var a = 0;
var b = ( a++, 99 );
console.log(a);  // a will be equal to 1
console.log(b);  // b is equal to 99
28 – Cache variables that need calculation or querying
In the case of a jQuery selector, we could cache the DOM element.
var navright = document.querySelector('#right');
var navleft = document.querySelector('#left');
var navup = document.querySelector('#up');
var navdown = document.querySelector('#down');
29 – Verify the argument before passing it to isFinite()
isFinite(0/0) ; // false
isFinite("foo"); // false
isFinite("10"); // true
isFinite(10);   // true
isFinite(undefined);  // false
isFinite();   // false
isFinite(null);  // true  !!!
30 – Avoid negative indexes in arrays
var numbersArray = [1,2,3,4,5];
var from = numbersArray.indexOf("foo") ;  // from is equal to -1
numbersArray.splice(from,2);    // will return [5]
Make sure that the arguments passed to splice are not negative.
31 – Serialization and deserialization (working with JSON)
var person = {name :'Saad', age : 26, department : {ID : 15, name : "R&D"} };
var stringFromPerson = JSON.stringify(person);
/* stringFromPerson is equal to "{"name":"Saad","age":26,"department":{"ID":15,"name":"R&D"}}"   */
var personFromString = JSON.parse(stringFromPerson); 
/* personFromString is equal to person object  */
32 – Avoid the use of eval() or the Function constructor
Use of eval or the Function constructor are expensive operations as each time they are called script engine must convert source code to executable code.
var func1 = new Function(functionCode);
var func2 = eval(functionCode);
33 – Avoid using with() (The good part)
Using with() inserts a variable at the global scope. Thus, if another variable has the same name it could cause confusion and overwrite the value.
34 – Avoid using for-in loop for arrays
Instead of using…
var sum = 0; 
for (var i in arrayNumbers) { 
    sum += arrayNumbers[i]; 
}
…it’s better to use…
var sum = 0; 
for (var i = 0, len = arrayNumbers.length; i < len; i++) { 
    sum += arrayNumbers[i]; 
}
As a bonus, the instantiation of i and len is executed once because it’s in the first statement of the for loop. Thsi is faster than using…
for (var i = 0; i < arrayNumbers.length; i++)
Why? The length of the array arrayNumbers is recalculated every time the loop iterates.
NOTE : the issue of recalculating the length in each iteration was fixed in the latest JavaScript engines.
35 – Pass functions, not strings, to setTimeout() and setInterval()
If you pass a string into setTimeout() or setInterval(), the string will be evaluated the same way as with eval, which is slow. Instead of using…
setInterval('doSomethingPeriodically()', 1000); 
setTimeout('doSomethingAfterFiveSeconds()', 5000);
…use…
setInterval(doSomethingPeriodically, 1000); 
setTimeout(doSomethingAfterFiveSeconds, 5000);
36 – Use a switch/case statement instead of a series of if/else
Using switch/case is faster when there are more than 2 cases, and it is more elegant (better organized code). Avoid using it when you have more than 10 cases.
37 – Use switch/case statement with numeric ranges
Using a switch/case statement with numeric ranges is possible with this trick.
function getCategory(age) { 
    var category = ""; 
    switch (true) { 
        case isNaN(age): 
            category = "not an age"; 
            break; 
        case (age >= 50): 
            category = "Old"; 
            break; 
        case (age <= 20): 
            category = "Baby"; 
            break; 
        default: 
            category = "Young"; 
            break; 
    }; 
    return category; 
getCategory(5);  // will return "Baby"
38 – Create an object whose prototype is a given object
It’s possible to write a function that creates an object whose prototype is the given argument like this…
function clone(object) { 
    function OneShotConstructor(){};
    OneShotConstructor.prototype= object; 
    return new OneShotConstructor();
}
clone(Array).prototype ;  // []
39 – An HTML escaper function
function escapeHTML(text) { 
    var replacements= {"<": "<", ">": ">","&": "&", "\"": """};                     
    return text.replace(/[<>&"]/g, function(character) { 
        return replacements[character]; 
    });
}
40 – Avoid using try-catch-finally inside a loop
The try-catch-finally construct creates a new variable in the current scope at runtime each time the catch clause is executed where the caught exception object is assigned to a variable.
Instead of using…
var object = ['foo', 'bar'], i; 
for (i = 0, len = object.length; i
…use…
var object = ['foo', 'bar'], i; 
try {
    for (i = 0, len = object.length; i
41 – Set timeouts to XMLHttpRequests
You could abort the connection if an XHR takes a long time (for example, due to a network issue), by using setTimeout() with the XHR call.
var xhr = new XMLHttpRequest ();
xhr.onreadystatechange = function () { 
    if (this.readyState == 4) { 
        clearTimeout(timeout); 
        // do something with response data
    } 
var timeout = setTimeout( function () { 
    xhr.abort(); // call error callback 
}, 60*1000 /* timeout after a minute */ );
xhr.open('GET', url, true); 

xhr.send();
As a bonus, you should generally avoid synchronous XHR calls completely.
42 – Deal with WebSocket timeout
Generally when a WebSocket connection is established, a server could time out your connection after 30 seconds of inactivity. The firewall could also time out the connection after a period of inactivity.
To deal with the timeout issue you could send an empty message to the server periodically. To do this, add these two functions to your code: one to keep alive the connection and the other one to cancel the keep alive. Using this trick, you’ll control the timeout.
Add a timerID
var timerID = 0;
function keepAlive() {
    var timeout = 15000; 
    if (webSocket.readyState == webSocket.OPEN) { 
        webSocket.send(''); 
    } 
    timerId = setTimeout(keepAlive, timeout); 
function cancelKeepAlive() { 
    if (timerId) { 
        cancelTimeout(timerId); 
    } 
}
The keepAlive() function should be added at the end of the onOpen() method of the webSocket connection and the cancelKeepAlive() at the end of the onClose() method.
For example, instead of using…
var min = Math.min(a,b);
A.push(v);
…use…
var min = a < b ? a : b;
A[A.length] = v;
44 – Don’t forget to use a code beautifier when coding. Use JSLint and minification (JSMin, for example) before going live.
45 – JavaScript is awesome: Best Resources To Learn JavaScript
·         Code Academy JavaScript tracks: http://www.codecademy.com/tracks/javascript
·         Eloquent JavaScript by Marjin Haverbeke: http://eloquentjavascript.net/
·         Advanced JavaScript by John Resig: http://ejohn.org/apps/learn/
Conclusion
I know that there are many other tips, tricks and best practices, so if you have any ones to add or if you have any feedback or corrections to the ones that I have shared, please adda comment.
References
In this article I have used my own code snippets. Some of the snippets are inspired from other articles and forums:
·         Google Code JavaScript tips
·         StackOverFlow tips and tricks
·         TimeOut for XHR

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget