Search code examples
javascriptfunctionvariableshandsontable

Declare variable as function value at a given time - not the function itself


I am trying to declare a variable with the value returned by a function:

var myValue = hot.getSettings();

However, the value of myValue keeps changing when the return value of getSettings() change. How can I define myValue as the current value of the getSettings() function, and save that value in myValue, even if getSettings change?


Solution

  • Your problem it that hot.getSettings(); return a reference not a copy of variable So you just need to clone that variable

    try this :

    var value = hot.getSettings();
    var myValue = $.extend(true, {}, value);
    

    I hope it will help.