1 function getFnName(fn){ 2 return typeof fn !== ‘function‘? 3 undefined: 4 fn.name || 5 /function (.+)\(/.exec(fn + ‘‘)[1] 6 } 7 8 9 function Person(){} 10 11 var i = new Person(); 12 13 var name = getFnName(i.constructor); 14 15 alert(name)
时间: 2024-10-11 02:28:01