« first day (1287 days earlier)      last day (3662 days later) » 

1:00 PM
@redshift ever used a clock?
 
a what?
 
@redshift It's easier than doing x - y*Math.floor(x/y) :)
 
There are smarter examples, with encryption that are way cooler. A clock is the simplest example I can think of.
 
!!> var arr= ['a','b','c','d']; arr[Date.now()%arr.length]
 
@dystroy "a"
 
1:01 PM
!!> var arr= ['a','b','c','d']; arr[Date.now()%arr.length]
 
@Connor "a"
 
i see wut u did thar
 
@redshift Most commonly it's used to determine even/odd.
 
@MichaelBruyninckx Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
@Connor "c"
 
ah
 
1:01 PM
FizzBuzz is another example where it works. Although, I like my solution better :)
My solution has no mod :D
 
!!> var a = 'abcdefghijklmnopqrstuvwxyz1234567890.',i = 18, j = 0,b = [a[i++],a[++i],a[++j],a[--i-1],a[i],a[--i-1],a[++j*(j+j)],a[--i-(j+j)],a[j*j+j]].jo‌​in(''),f = function(x,y) { switch(x){case(1):o=y;break;case(0):l=y;break;} return y; }, o,l,c = [a[b](i+j)[0], a[b](i++,i), f(1,a[b](--i-(++j),i-(--j))), f(0,a[b](--i-((j++)+j), (i++)-(--j+j))) ].join(''),e = o + l,d = c+Array(++j+j).join(e); d;
 
@rlemon "undefined"
 
cool thing is i understand that code, Connor
 
@rlemon "trolololololol"
 
alright back to learning i go
see ya room
 
1:02 PM
@redshift Good luck!
 
for (var i=0; i<100; i++) {
    if ( i % 4 === 0 )
        console.log('Every fourth');
}
It's useful for so many things !
 
var repeat = function*(arr) { while(true) for(var i = 0; i < arr.length; i++) yield arr[i]; }

var fizz = repeat(['','','Fizz']), buzz = repeat(['','','','','Buzz']);

for(var i = 1; i <= 100; i++)
    console.log(fizz.next().value + buzz.next().value || i);
:D
Much nicer than mod checks.
 
regardless how smart that might be.. a code which voluntarily uses while(1) should be questioned :p
 
@jAndy yes, for(;;) is one char shorter
 
1:05 PM
I got codeacademy open, so if i have any questions, i'll be sure to ask here
 
while(1) break; // fooled you
 
Serious question : Are there non null numbers in javascript which are equal to their opposite ?
 
for(;;) {
    while(1) continue fool;
    fool: break;
}
y u no work
haha.. what does that say about this channel
 
var repeat = function(arr) {return {val: 0, next: function(){return arr[this.val++]}}}
 
you have to pre-tag serious questions with serious question: now
 
1:10 PM
well... sometimes we'd need the tag...
 
room topic changed to JavaScript: Read this link or we'll eat you: rules.javascriptroom.com. Before asking a question inform yourself on the XY problem goo.gl/taIqf [ecmascript] [ecmascript-5] [javascript]
I can't stand those messed up channel names
 
why ? No love for ES6 and ES7 ?
 
I didn't touch the tags tho :p
 
@kaffein Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@dystroy they dont exist yet
 
1:13 PM
@intrueder Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@DrogoNevets What does that mean ? Do HTML5 exist ?
 
Is anybody of you fammiliar with phonegap platform?
 
@AlexStanese no
 
ok -_-
 
@AlexStanese he is trolling you because you ignored the welcome message
 
1:14 PM
@AlexStanese just ask your question. Many of us did small things in phonegap. Even if we're not fammmiliar.
 
@jAndy no i'm trolling him because he's asked the same question like 4 times a day for like 4 days.
 
oke... prepare for a long journey :))
so I have this script someone helped me to achive and it doesn't work when I implement it in phonehap.. Sometimes the bug also appears in the web version. SO I have 5 lives wich regenerates after 15 seconds each and sometimes they regenerate sometimes they dont regenerate..
student.sps-prosek.cz/…
They should regenerate also if the tab (and app) is closed
in the phonegap app they never ever regenerate when th app is closed...
the date is not set when I reenter it..
I also made today the whole day some steps on the mobile version to try and find the bug...
 
uhm
 
Oh. So none of us know anything about phonegap, sorry, was wrong.
 
and that is the second time today i've seen that wall
-_-
 
1:16 PM
@rlemon I was trying the whole week for an answer.. I stayed the whole days to resolve that bug
@rlemon but its so less phonegap support!!
 
2
A: Candy Crush Saga Type countdown life system jQuery & Phonegap

AkxeIn this code I use the localStorage since they are available on all platforms and web. Using local storage you will get better cross platform compatibility: WebStorage (localStorage & sessionStorage) IndexedDB SQL-Storage Localstorage is array, but every element can only have string in it (us...

here is his code and issue.
@AlexStanese start another Q on SO then
 
@rlemon yes but the short version if you dont want to read all the comments is the above pasted wall
 
 
honestly. you are likely to get better answers there. more people view main
 
@dystroy there are standards that have started to be implmented across al major browsers so yes
 
1:17 PM
am I a pig if I responded to that facebook post with: I read "cock wild" ?
 
@Dalek Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
I mean...
 
@DrogoNevets so ES6 exists
 
@jAndy due to a misplaced leaf I read "cock wild"
 
its looks like cock at first glance :P
YEA!
 
1:18 PM
How do I cheat at playsnake.org ?
 
@Dalek hacking the flash
!!google cheat engine
 
How do I cheat my bank ?
 
@dystroy in all major browsers?
 
cheating flash games takes the fun out of the flash games
 
1:19 PM
@jAndy bitcoin.org
 
and it is way too easy
 
@rlemon on the contrary, cheat engine is pretty fun
 
for the first week or so (imo)
then I got bored of it
 
@Ca
 
@rlemon ive not used that in years!
 
1:20 PM
same with .SOL editor
 
@DrogoNevets Are you really willing to argue that ES6 doesn't exist because Microsoft didn't start to implement it ?
 
@CapricaSix That is only for windows; I use linux...
 
use Windows.
 
@CapricaSix I have standars
standards*
 
Apparently not, you are hacking a flash game.
 
1:20 PM
@CapricaSix Touché
 
p.s. I am a bot. (rlemon is just having fun)
 
@CapricaSix Me too! We should meet
 
anybody here used bitcoins really :P ?
 
!!tell Dalek help
 
@Dalek Information on interacting with me can be found at this page
 
1:21 PM
@jAndy I know @Jhawins was into it
 
@Jhawins summoning
 
@dystroy it means it cannot safely be used, and looking at MDN it is "not cimpliant with current spec" in alot of places so yes
 
great, lost my FTDI cable.
:(
 
ROOM POLL: would the use of Function(); twice in a framework put you off?
 
@DrogoNevets so you deduce ES6 doesn't exist and shouldn't be spoken about... You're a troll...
 
1:24 PM
@Connor I don't care about the total; I care about the density.
 
@dystroy didnt say it shouldnt be spoken about
 
@KendallFrey what do you mean?
 
If you mean the Function function, only a density of about 0.1 calls per line would matter to me
 
@Connor Strange question. Context ?
 
Why is Javascript better than Haskell?
 
1:28 PM
Ask @BartekBanachewicz
 
question-of-the-year-award goes to: DALEK
 
Basically, I disagree with the "security risk" side of Function, I really don't understand it, if you add 3rd party scripts to your page the have access to the global scope and can do anything, anyone does, anyway I am basically using it to parse Javascript expressions like in angularjs, but it's not so simple, say if you done this expression getName() && eval('user')
it would be kinda translated to this new Function(' return scope.getName() && scope.eval('user'); ') so unless you specifically define eval on your scope it wont work, what do you think about this?
 
@jAndy Yeah, but it would be better in main... where we can vote...
 
But you only parse the expressions once, then you have the real function you can use whenever you want, expressions will never be parsed with Function more than once
@dystroy @KendallFrey what do you think?
It would be faster and better IMO than writing own compiler/parser
 
context of the context ?
 
1:30 PM
You mean using Function instead of eval? gross
 
@dystroy what you mean?
@KendallFrey no
I said nothing about eval
 
I mean Function and eval are dangerous in some contexts, not all.
 
@dystroy The point I'm trying to make is everything is scoped down to scope and there is no way to access the global scope within expressions, would you accept that?
 
Where would I accept that ? If you mean injecting code in a browser inputted by another user, heck, no.
 
unless of course you added window to your scope, but then it would all be on you
 
1:32 PM
you can get window in your scope easily
var window = (function(){ return this }).call(null)
(ok, not in strict)
 
@dystroy I'm talking about expressions like in angularJS, functions are not allowed in expressions
they are basic expressions
 
how do you know that without parsing ?
 
@dystroy Yes, I'm working with the expression string a bit, adding the scope before variables, checking safety and all that then the validated expression goes through the Function process
 
How do you check safety ?
 
@dystroy By working with the string and validating what it in the expression against what's allowed
do you not follow?
 
1:39 PM
Why is [100,100,100,100].map(parseInt) equal to [100,NaN,4,9]?
 
because the second parameter to the callback is the index of the item
so it would be
parseInt(100, 0)
parseInt(100, 1)
parseInt(100, 2)
parseInt(100, 3)
 
and parseInt expects a radix
 
!!> parseInt(100, 1)
 
@Connor "NaN"
 
^
 
1:42 PM
parseInt should be removed from the language entirely
parseFloat ftw
 
!!> parseFloat.length
 
@C5H8NNaO4 1
 
!!> parseInt("08");
 
@jAndy 8
 
when did they fix that ?
 
1:43 PM
Thanks!
 
@jAndy do that with parseFloat : stackoverflow.com/questions/23277585/…
@jAndy A long time ago but browsers didn't all change at the same time
 
define 'a long time'
I obviously never use parseInt like so, I can't tell
 
@jAndy what I perceive as a long time. In that case it should be 3 to 5 years for the first browser to change
 
Why are both 1.6 < 1.2 < 0.8 and 1.6 > 1.2 > 0.8 true?
 
> If radix is undefined or 0, it is assumed to be 10 except when the number begins with the character pairs 0x or 0X, in which case a radix of 16 is assumed. §15.1.2.2
 
1:47 PM
@jAndy Vanilla + require or browserify. Because I find Vanilla more fun than frameworks.
 
@dystroy +('0x' + (n).toString(16));
 
@jAndy This being said, I wholly agree with you on the important point. I find it stupid to see it used so often, especially in SO answers. It's mostly due to developers not knowing what are numbers in js
 
I didn't really look what your code was doing
 
@RyanKinal agreed. Its way more fun
 
@rlemon not enough parseFloat, but yes that's a way ^^
 
1:48 PM
@C5H8NNaO4 but that can be different based on implementation. it is always best to provide a radix.
 
@RyanKinal what about efficiency and convenience ?
 
0
Q: Why the values of checked elements from select control are not coming in $_POST array after submission of form?

PHPLoverI've following HTML code: <form action="rebates.php" role="form" method="post"> <select id="example28" multiple="multiple" name="applicable_states"> <option value="" selected='selected'>Select Unit</option> <option value="1" >Alabama</option> <option value="2" >Alaska</option> <...

 
In ES5, the radix is supposed to be 10 in parseInt("08") : es5.github.io/#x15.1.2.2
 
@SteveA Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@rlemon Yeah, indeed. But that would explain why parseInt ("08") === 8 instead of 0
 
1:49 PM
@BenjaminGruenbaum Which answer would that be?
 
@jAndy It's a consideration. I think it depends on the project, but if you have a decent set of vanilla libraries (think microjs style), then you can pick and choose what you need.
Oops, mis-ping
 
i have an extreme newbie question
I have the following conditional statement:

if (myName == "Amber") {
console.log("What a beautiful name!");
}
else {
console.log("That name sucks!");
}
how do i prompt the user? prompt("what is your name?"
 
@Dalek It's not. Haskell is way better than JavaScript.
 
and how do i get the value to put in to the condition statement to work
 
prompt returns the user input
so, var myName = prompt(...)
 
1:54 PM
i thought i had tried that, but didn't work, let me try again
ok i did it again it worked lol
sorry
 
of course, prompt is not exactly nice as a user interface
 
im on codeacademy learning the basics, but what is the recommended way to prompt? alert
?
 
build your own input
html + css modal prompt
 
@redshift reccomended depends purely on your application
 
of course, but learning javascript at th emoment
 
1:56 PM
have an form with an input element, then listen to submit events
or to click events + enter key presses
 
if you are wantoing debug output and have learnt the wonders of firebug/web inspector use console.log
 
he's capturing user input
 
does anyone know where to learn how to use chrome dev tools?
there are so many things u can do with it, i only know a small percentage
 
By using it
 
@redshift practice
 
1:57 PM
google is a great start.
 
when will chrome devtools take the place of a IDE
 
never
 
cheese
 
@redshift github.com/ryankinal/capjs <--- non-blocking, HTML-based alternative to prompt
 
1:58 PM
@rlemon +1
 
Chrome Devtools can't save javascript files
 
@redshift the job an ide does is VERY different to dev tools
 
rlemon.github.io/Notifier.js <--- non-blocking, HTML-based alternative to alert
 
@redshift its like a chef vs butcher
 
@JanDvorak Actually... I'm pretty sure it can, if you set it up right.
 
1:59 PM
@RyanKinal nice
 
@JanDvorak Thanks :-)
 
@RyanKinal Y U NO DEMO PAGE?!
 

« first day (1287 days earlier)      last day (3662 days later) »