Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28012
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Make own type (object) type in javascript. |
| Date | 2015-06-07 02:40 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <2283260.pclIp03G5q@PointedEars.de> (permalink) |
| References | <66362d49-af1e-400b-b026-0e6d9b679f98@googlegroups.com> <87iob0l79e.fsf@bsb.me.uk> |
Ben Bacarisse wrote:
> jonas.thornvall@gmail.com writes:
>> Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit
>> that still can be treated as a numerical value that can be added and
>> subtracted, without bit operations?
>
> No.
var o = {
valueOf: function () {
return (+!!this.bit3) * 4 + (+!!this.bit2) * 2 + (+!!this.bit1);
}
};
o.bit2 = 23;
/* 42 */
40 + o
/* 23 */
25 - o
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
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
Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 15:11 -0700
Re: Make own type (object) type in javascript. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-07 00:57 +0100
Re: Make own type (object) type in javascript. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-07 01:33 +0100
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 17:37 -0700
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 17:50 -0700
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 18:03 -0700
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 18:07 -0700
Re: Make own type (object) type in javascript. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-07 10:19 +0100
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-07 04:09 -0700
Re: Make own type (object) type in javascript. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-07 02:40 +0200
csiph-web