Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home JavaScript
 

JavaScript Void Operator

 

Void operator is a form of tool used in JavaScript that allow developers to "infect" their application with a void function. Voiding some functions are sometimes needed by developers who wanted to put a stop in a function but unable to disable specific functions.


Instead of destroying the coding, developers can simply provide the void operator to abruptly end the function. While there are other options that might work well (or even better) compared to void functions, there are still situations where void is the perfect solution.


Implementing JavaScript Void


Syntax


void: function


At first glance, void operator can be identified with other functions in Ajax or JavaScript. But its implementation is quite unique since they will not require the developers to push the operator in the function.


The void operator will actually work as an independent reference or a link that will be part of the function. This will allow developers to put a stop on the specific function without affecting the system. Developers can practically refer to the operator as a "power switch" wherein everything stops without affecting the system.


Reaching the Undefined Function


The main reason why developers add the void operator is to obtain the "undefined" result. While "undefined" is not necessarily a useful function, there are situations that calls for this type of return. A good example is the extension of strings so that the function will have a different result.


Aiming for a void operator will ultimately stop the function but will pave the way for a new function in the application. Of course, the previous function will be ignored or some of its data will be used in other operations but the string has ended.


Events vs. URI


As already indicated, there are options for developers who do not want to use void operator. The reason why they opted to ignore void is the due to the use of the URI format. Using "void: object" format is URI and do not just place a stop in the JavaScript or Ajax operation. URIs can be easily detected by crawlers and can be used to attack the online application. Attacks can be in a form of another script that will tell the application of another function or to retrieve the needed data.


A good option for developers is the events functions. Developers who use events do not have to go through operators but will provide a different route for the function. Events will not only stop the function but will provide a different route which means no additional process is required. It's also safer compared to URI since it the even does not provide a clue for attackers on what has happened in the function and the next event.


Like most operators, it's highly recommended to proceed with caution when using the void operator. As much as possible, the operator have to be used in non-sensitive and independent functions so that the online application will still be protected even with an attack.



Read Next: The Eval() Function



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links