What is the correct way to “serialize” functions in javascript for later use

后端 未结 7 1554
温柔的废话
温柔的废话 2020-12-17 02:08

I have a \"library\" of objects that I want to load on the fly from a database. Each object comes with its own special functions that are called at specific times depending

相关标签:
7条回答
  • 2020-12-17 02:50

    what you are doing with it is just fine. However, if i were you, for readability and tidyness, i would rather have the function created outside and simply have it assigned to your object key.

    You don't need eval here. Instead do it this way whenever you want access to the stored function -

    library.myObj.function()

    0 讨论(0)
提交回复
热议问题