“method” method in Crockford's book: [removed] The Good Parts

前端 未结 5 1637
不知归路
不知归路 2020-12-04 17:13

Douglas Crockford wrote in his book (Page 4):

Throughout the book, a method method is used to define new methods, This is its definition:



        
5条回答
  •  既然无缘
    2020-12-04 17:44

    As an aside, on P40:

    The end () means "use the function that this function returns", not the outer function that returns it.

    If he had left off the final (), a call to deentityify would return a function, rather than a string.

    In Douglas Crockford's own words:

    We immediately invoke the function we just made with the () operator. That invocation creates and returns the function that becomes the deentityify method.

提交回复
热议问题