Please tell me which time point the data retrieved when the API was called is based on?

Author: guigui17f, Created: 2017-10-31 18:38:15, Updated: 2017-10-31 18:48:57

Can you give a brief explanation of the time points on which GetTicker and GetRecords are based when retesting? For example, I encountered this very strange problem, with this code: function main (() { while (true) { var records = exchange.GetRecords (); records.pop (((); Log ((records.length); Sleep ((60000); I'm not sure. I'm not sure. The last output record has always been 0:img

But if you omit the pop ((() call: function main (() { while (true) { var records = exchange.GetRecords (); // records.pop (); Log ((records.length); Sleep ((60000); I'm not sure. I'm not sure. The final output is normal:img

If there is no whilst loop, then it is OK to keep the pop ((() call: function main (() { var records = exchange.GetRecords (); records.pop (((); Log ((records.length); Sleep ((60000); I'm not sure.img

Can you answer that?


More

ZeroThe arrays that GetRecords returns are actually the same variables that are maintained at the lower level, so they cannot be changed directly.

guigui17fMaybe it's due to the features of the js language? I copied it with slice ((() once and it's okay, I don't understand why...

The Little DreamTry this deep copy function, deep copy every time records are retrieved, and then you can modify the variables after the copy. What's up? var cloneObj = function ((obj) { // Deep copy of the object function var str, newobj = obj.constructor === Array? [] : {}; if (typeof obj!== 'object') { return; } else if (JSON) { str = JSON.stringify ((obj); // object to be serialized newobj = JSON.parse ((str); // is rendered } else { for (var i in obj) { newobj[i] = type of obj[i] === 'object'? cloneObj ((obj[i])): obj[i]; cloneObj is a clone of Obj (i) and Obj is a clone of Obj. I'm not sure. I'm not sure. return newobj; I'm not sure. What's up?

The Little Dreamslice ((() This is a complete copy, not a reference. The reference operation is actually the same variable, and the next time you modify it, it will have an impact.

guigui17fIt turns out that this is the case. It is recommended to explain in the API documentation to prevent misuse.