Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32801

Re: Save instance of array "undo" and copy it back to array.

Path csiph.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Save instance of array "undo" and copy it back to array.
Date Sat, 18 Mar 2017 15:01:08 +0100
Organization PointedEars Software (PES)
Lines 69
Message-ID <1968884.iZASKD2KPV@PointedEars.de> (permalink)
References <358e280c-4521-42fe-abcb-6926efa129c4@googlegroups.com> <5y5t1y7xyqf0$.1g6m6w8017g2$.dlg@40tude.net>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1489845668 30186 eJwNyskRACAIBLCW5FqgHETsvwSdfGMCQrvCoHa/ZC7cUMbEqpJYtOFMlvtEe5+JyoCr/jDyAAjGEIs= (18 Mar 2017 14:01:08 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Sat, 18 Mar 2017 14:01:08 +0000 (UTC)
User-Agent KNode/4.14.2
Cancel-Lock sha1:nT7iNUZBNAkILbqxEpLO/gEvtx4=
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
X-NNTP-Posting-Host eJwNyMEBwCAIA8CVUEjQccSS/Uew9zw4B28GwYCgavOayAP5VnOtM6dyiOi/Taq4H2yXtfH2AyDMEWU=
X-User-ID eJwFwYEBgDAIA7CXBrQUz0Em/59gwkjLEZIJLndatqMJht7X3VBzxgssQKUNi9ZjOF9e5xXE4aJv78nOHzmYFNM=
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Xref csiph.com comp.lang.javascript:32801

Show key headers only | View raw


JJ wrote:

> On Fri, 17 Mar 2017 02:00:39 -0700 (PDT), jonas.thornvall@gmail.com wrote:
>> If not, how would one go on calculate it?
> 
> It depends on what type of values are stored in each array element.

Most certainly not.  The values referred by array elements are most 
certainly _not_ part of the memory required for storing the array.  An 
efficient implementation would store pointers in the array only. 
 
> - Boolean type only need one byte but is rounded up to either 32-bit or
> 64-bit integer [1].

No, it depends on the implementation of ECMAScript.
 
> - Number type is a 64-bit floating point number.

At minimum, to satisfy IEEE 754 requirements.
 
> - String type is either a 32-bit or 64-bit integer [1] which is a memory
> pointer pointing to the actual UTF-8 string data. i.e. it has two data:
> pointer & text.

Again, that depends on the implementation.
 
> - Date type is […]
> - Object and Array types are […]
> - Function type is […]

See above.

> […] a structure array […]

Another figment of your vivid imagination.

> depending on the JavaScript engine.

Not “JavaScript engine”, but _implementation of ECMAScript_.  The various 
languages whose name contains “JavaScript” are _not_ the only 
implementations of ECMAScript.

You have been told this before ad nauseam.  Will you *ever* learn?
 
> In your example code, the operation would be the assignment of the array
> element.

Which is _not_ a “variable assignment”, but a property-write access.

> Since undoing a variable assignment requires you to know the
> original variable value, you'll need to store the original value before
> the variable assignment is actually performed. I'd recommend using the
> `Object.watch()` to do this.

Even your half-knowledge is out of date.  Object.*prototype*.watch() is 
proprietary (implementation-dependent, precisely SpiderMonkey-only), 
intended for *debugging*, and is deprecated (in favor of getters/setters 
and/or Proxy, I presume).

Object.observe(), which you might have meant instead, is proprietary, and 
deprecated in favor of getters/setters and/or Proxy, too.

<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch> pp.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Save instance of array "undo" and copy it back to array. jonas.thornvall@gmail.com - 2017-03-17 02:00 -0700
  Re: Save instance of array "undo" and copy it back to array. JJ <jj4public@vfemail.net> - 2017-03-18 18:53 +0700
    Re: Save instance of array "undo" and copy it back to array. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-03-18 15:01 +0100

csiph-web