One of the properties of JavaScript functions is the name property. This saves the name of the function as a string. For named functions, ie...

function a() {...}

console.log(window.a.name) returns "a".

for unnamed functions, ie...

window.b = function() {...}

console.log(window.b.name) returns "" (as it should).

However, when this specific case happens...

var c = function() {...}

console.log(window.c.name) returns "c" when it should instead return "".

I've tried this on firefox, and have not been able to repeat the error, making me think this is a chrome specific bug, or "feature". I haven't experienced this causing issues for me, but the whole purpose of the function "name" property seems to be that it keeps the name intact despite whatever reference or pointer, wherever it may be in your code. Is anyone else able to repeat this error in their browser console? Is this an issue in Google Chrome's code?

0 Answers