Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #24746 > unrolled thread
| Started by | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| First post | 2014-06-11 22:48 +0200 |
| Last post | 2014-06-11 22:48 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.javascript
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: "i = i|0" "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-06-11 22:48 +0200
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2014-06-11 22:48 +0200 |
| Subject | Re: "i = i|0" |
| Message-ID | <XnsA349E8160EEAEeejj99@194.109.133.133> |
ram@zedat.fu-berlin.de (Stefan Ram) wrote on 11 jun 2014 in
comp.lang.javascript:
> Newsgroups: comp.lang.c,comp.lang.javascript
Response for comp.lang.javascript
> I have read this in a World-Wide Web encyclopedia:
>
> For example, given the following C code:
>
> int f(int i) {
> return i + 1;
>}
I have no idea what that means.
> Emscripten
What is that?
> would output the following JS code:
>
> function f(i) {
> i = i|0;
> return (i + 1)|0;
>}
> Do you think that the ť|0Ť is necessary to express the
> C semantics in JavaScript,
What is "C semantics"?
Why would you want to do that and not just write javascript?
What other types of i would you want to catch?
btw, i could be a string, a floating point, would you allow that?
var i = 'Hello';
alert(i|0); // 0
alert(i||0); // Hello
alert('yes'|'maybe'); // 0
alert('yes'||'maybe'); // yes
alert(''||'maybe'); // maybe
> or could the speed of the
> generated code be improved by omitting it?
var i = 'Hello';
alert(f(i));
function f(i) {
return i++;
};
This will return NaN,
[which is NOT an error!]
and then you deal with that.
However, better be sure of your code
and the effective subtypes
of the variable values you are using.
Javascript has no typed variables.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to top | Article view | comp.lang.javascript
csiph-web