简体   繁体   中英

can't change function.name in VS Code with node.js

I learned that I can change the name property of the function this way but it doesn't work. What did I wrong? Thanks in advance.

 const tFunc = a => a**2; console.log(tFunc.name); tFunc.name = 'cruella'; console.log(tFunc.name);

From MDN :

A Function object's read-only name property indicates the function's name as specified when it was created, or it may be either anonymous or '' (an empty string) for functions created anonymously.

It is a read only property. You can't change it.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM