Skip to content
Related Articles

Related Articles

Improve Article

JavaScript Error.prototype.columnNumber property

  • Last Updated : 20 Aug, 2021

The columnNumber is a non-standard property that contains the column number of the line at which the error was raised. It is recommended to not use this property on production sites facing the web, as it may not work for every user. 

Use: This property is useful while creating an error object. If the column number is undefined for any error object, you can define it manually.

Syntax:

error.columnNumber

Javascript




try {
    // Creating a new error object
    var err = new Error ("Format not supported","filename",0);
    if(err.columnNumber == undefined)
        err.columnNumber = 0;
    throw err;
}
catch(e) {
    // Printing error message
    console.log ("Error: " + e.message);
    // Printing column number of line
    // at which error was raised
    console.log ("At Column number: " + e.columnNumber);
}

Output: 



Error: Format not supported
At Column number: 0

Javascript




try {
    // Creating new error object
    var err = new Error ("Unexpected token output","filename",0);
    if(err.columnNumber == undefined)
        err.columnNumber = 0;
    throw err;
}
catch(e) {
    // Printing error message
    console.log ("Error: " + e.message);
    // Printing column number of line
    // at which this error was raised
    console.log ("At Column number: " + e.columnNumber);
}

Output: 

Error: Unexpected token output
At Column number: 0

Browser compatibility(Desktop): 

  • Firefox

Browser compatibility(Mobile): 

  • Firefox for Android

 




My Personal Notes arrow_drop_up
Recommended Articles
Page :