I know there is a reserved keywords . I just want to use it anyway. Is it related to the interpreter?
All function names are actually variables holding a reference to an object of type Function
. Most often these variables are properties/keys into the global namespace (eg window
in browsers and global
in Node.js)
So it is entirely possible to write something like this:
global.return = function()
{
console.log('test');
}
global.return();
Of course you can not call it simply by return()
as this will choke the parser - but global.return()
or global.import()
or global.switch()
is completely achievable.
Its a bad idea to override a reserved function name in any language. Why not change your function name to have a prefix like 'custom'
function customName() {}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.