Return all of the functions that are defined in a Javascript file

前端 未结 4 1903
孤独总比滥情好
孤独总比滥情好 2020-11-27 19:53

For the following script, how can I write a function that returns all of the script\'s functions as an array? I\'d like to return an array of the functions defined in the sc

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 20:13

    function foo(){/*SAMPLE*/}
    function bar(){/*SAMPLE*/}
    function www_WHAK_com(){/*SAMPLE*/}
    
    for(var i in this) {
    	if((typeof this[i]).toString()=="function"&&this[i].toString().indexOf("native")==-1){
    		document.write('
  • '+this[i].name+"
  • ") } }

提交回复
热议问题