Function.prototype.toString()

方法返回一个表示当前函数源代码的字符串。

       function sum(a, b) {
            return a + b;
        }

        console.log(sum.toString());
        // expected output: "function sum(a, b) {
        //                     return a + b;
        //                   }"
        
        // expected output: "function abs() { [native code] }"
        console.log(Math.abs.toString());

  

posted @ 2020-03-24 16:14  banzhuxiang  阅读(131)  评论(0)    收藏  举报