Void ( ) Operator

Video

JavaScript Notes

JavaScript
    // void.js
    // Using the void (expression) operator
    void ( console.log('sample void'));		// returns nothing as a function, but still shows ‘sample void’
                                            // allows you to use void operator in href tags of html
    							            // e.g. href=”javascript:void(console.log(‘sample text’))"
    							            // runs function expression, but doesn’t return anything, so href doesn’t take you anywhere
    function x( ){
    	let a = 1;
    };
    
    let abc = x( );						    // will return the word ‘undefined’, and why we might want to use the void function instead, so that nothing is returned