标签:
Each function should have a ‘name‘ property. It can be anonymous, empty, the same as function name, or class name.
For example:
const foo = function(){} console.log(foo.name); //foo
function(){ .. }); // name: (function*(){ .. }); // name: window.foo = function(){ .. }; // name: class Awesome { constructor() { .. } // name: Awesome funny() { .. } // name: funny } var c = class Awesome { .. }; // name: Awesome var o = { foo() { .. }, // name: foo *bar() { .. }, // name: bar baz: () => { .. }, // name: baz bam: function(){ .. }, // name: bam get qux() { .. }, // name: get qux set fuz() { .. }, // name: set fuz ["b" + "iz"]: function(){ .. }, // name: biz [Symbol( "buz" )]: function(){ .. } // name: [buz] }; export default function() { .. } // name: default var y = new Function(); // name: anonymous var GeneratorFunction = function*(){}.__proto__.constructor; var z = new GeneratorFunction(); // name: anonymous
[Javascript] MetaProgramming: function name
标签:
原文地址:http://www.cnblogs.com/Answer1215/p/5581343.html