« first day (2241 days earlier)      last day (2710 days later) » 
00:00 - 21:0021:00 - 00:00

9:00 PM
maybe you can also look into mochajs.org, because Jasmine introduce the web-based test runner pretty late and I'm not sure whether their setup is still FUBAR in on it's own
 
test
 
@s.brody Welcome to the JavaScript chat! Please review the room 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.
 
it worked
 
is this okay for a basic email matching? /.+@.+\..+/
 
@towc yup
 
9:07 PM
can emails have more than a single @?
 
nope, but you're letting illegal characters fly by
 
@FilipDupanović I should have [A-Za-z]+ instead of every .+?
 
!!> 'foo@$asdf$.com'.match(/.+@.+\..+/)
 
@FilipDupanović ["foo@$asdf$.com"]
 
@towc that and I think you need to support subdomains as well
 
9:11 PM
!!> 'foo@$asdf$.com'.match(/[A-Za-z]+@[A-Za-z]+\.[A-Za-z]+/)
 
@towc null
 
but then there's also all of the _ and the . in the username part...
urgh...
 
!!> 'foo@arsd4.foo.com'.match(/.+@[\w.]+\..+/)
 
@FilipDupanović ["foo@arsd4.foo.com"]
 
also, domains can have numbers in them
 
9:12 PM
yeah, so best use \w
 
urgh, I guess I'll just stick to the dots
 
@towc yup
 
@KendallFrey loves dots
 
Whats up guys
 
overflow
 
9:24 PM
-2
Q: URGENT ! Cannot read property

Cosmin TincuERROR : HELP CODE FROME INDEX . JS : http://pastebin.com/TvtQey5T

 
hello guys
i need a webdriver to test web and mobile apps
is a good idea to use selenium ?
 
we use it at work a bit, it's good
 
i used it too but i never used it for mobile apps
 
what's a webdriver? you mean test runner?
 
so annoying: .match returns either an array or null. Why not an empty array?
 
9:28 PM
no. i need a driver to access web elements
 
@towc so you can use !
 
!!> ![]
 
@towc false
 
oh
good point
 
@gtzinos who's writing the tests, you or QA?
because you can run headless tests on Chrome, FF and if you're using components you can even get away without needing full DOM access
 
10:00 PM
very interesting.
cc @Luggage ^
 
10:13 PM
imgur.com/gallery/cBU0c @SterlingArcher you like these kinds of things (TRIPLE PING)
 
@FlorianMargaine 1024cores.net
 
lor
Hi guys
I have a little question about decimals. I'm trying to make a calculator but when i multiply 0.02*0.02 (double both) i get an unexpected answer
I am looking for a fix
 
@lor Welcome to the JavaScript chat! Please review the room 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.
 
@FilipDupanović ?
 
all the sync algos out there for you to om nom on
 
10:23 PM
!!> .02 * .02
 
@Shmiddty 0.0004
 
@lor Probably because 0.02 can't be represented exactly, only an approximation
 
lor
I know, but it is annoying when I dont get the expected answer
 
Why?
 
@MadaraUchiha LOL
 
lor
10:27 PM
Now I'm trying to make a simple calculator on android and I have problem with these
 
i love it
 
Most situations don't require infinite precision
 
@lor you have limited precision
 
@SterlingArcher The comments though: "Nice! Leader!"
 
lor
What do you suggest?
:)
 
10:28 PM
either go for bigger precision or find a package that can work with big numbers that supports decimals
 
@lor I suggest figuring out what you want the calculator to be
 
lor
Well, it is a simple one... I want to keep it simple. I have problem with precision
 
Let me guess. You want infinite precision?
 
lor
No.
I want for example 0.1*0.1 do display 0.01, not 0.0100000000(other numbers here)
 
implement a simple "remove trailing zeros" function
 
10:31 PM
Is that because you want to limit precision on the display?
Or for some other reason?
 
lor
As I said, i get wrong results, there is no other reason except this :)
 
That result isn't necessarily wrong
You always have to deal with limited precision in computing, and thus use approximations
 
lor
I want to use approximations, for example if the result of 0.1*0.1=0.0100000000007289821 , make it 0.01
I think it is called rounding
 
So you want to limit precision for display purposes?
That's generally what rounding is used for
 
Can someone help me with a logic/Javascript problem? I have an array of arrays, each array contains a letter and a number. The number is how many times the letter occurs in a String.

They're in order from most frequent to least frequent. But I need to order them so if multiple occur the same amount of times then they get ordered alphabetically.

So say x, y, and a all occur 3 times. Then it would be ordered a,x,y
 
10:40 PM
!!> Number.parseFloat((0.1 * 0.1).toPrecision(10))
 
@FilipDupanović 0.01
 
lor
No. I dont have problem with the length
Filip I will try your suggestion
Thank you
 
@TristanWiley You can write a comparison function that checks the frequency and the letter, or you can sort by the letter and then the frequency, as long as you use a stable sort.
 
I'm so confused
Number[Symbol.hasInstance] = function(x) { console.log(x); return Number(x) === 4 };
4 instanceof Number; // no logs, no nothing :(
Happens to every callable I'm defining Symbol.hasInstance of
 
prototype?
 
10:48 PM
But it does GetMethod(callable, @@hasInstance)
Plus you define it on objects directly, it'll make no sense for it to go to something.prototype
 
lmfao hold up, I just accidentally solved my problem
 
what if you want all instances of something to be something else?
 
If this works I'm going to laugh my ass off
Literally, I'm going to have to buy a new ass
Or at least invest in some superglue
 
var o = { [Symbol.hasInstance](x) { console.log(x); return Number(x) === 4 } };
4 instanceof o;
// this works
And Array[@@hasInstance] is defined
So confused
 
10:55 PM
Wrong tab
 
Has anyone here seen Moana?
 
11:07 PM
if anyone is feeling bored
gist: 63fcd74bbbd8508d70c75c2b66963f3c, 2016-12-04 23:07:28Z
/**
    * @name traverse
    * traverse an object with a callback.
    * @param {object|array} obj object to traverse.
    * @param {function} cb callback for each node. will be called for each node,
    * with the value and current path to the node from the root object, as well
    * as a third value to be true if the node is an object.
    * @returns {undefined} N/A
    */

// TODO improve perf
function traverse(obj, cb, context = '') {
    let keys = [],
        objs = [],
        paths = [];
        for (let k in obj) {
            keys.push(k);
            objs.push(obj);
            paths.push(context);
        }
    for (let i = 0, len = keys.length; i < len; i++) {
        const key = keys[i];
        const obj = objs[i];
        const val = obj[key];
        const context = paths[i];
        const path = context ? context + pathSplitter + key : key;
        const isObj = isObject(val);

        const shouldContinue = cb(val, key, path, obj, isObj);

        if (isObj && shouldContinue !== false) {
            const keyObj = obj[key];
            for (let k in keyObj) {
                keys.push(k);
                objs.push(keyObj);
                paths.push(path);
                len++;
            }
        }
    }
}
help me optimize this beauty
following advice from @FlorianMargaine
 
11:23 PM
I'm so sorry
 
about what :X
 
@Mosho it looks wrong?
 
passes all the tests
 
Oh my god
 
I FUCKING DID ITTTTT
 
11:32 PM
Are you really pushing to an array while looping over it?
 
yup
I edited it now
a little better
 
Oh god, I just understood the code
 
but yeah, that's the best I could come up with
 
You should feel ashamed to have written that
 
:(
 
11:34 PM
Nice one tho
 
it's a lot faster than the recursion
^^
 
Oh yeah?
 
the same for small input
but scales much better
saw it do half the time for bigger objects
 
Nice
@Mosho have you tried using TCO instead?
 
I just tought about that
 
11:36 PM
Not sure if it's feasible
 
I'll look into it
 
V8 supports it, right?
 
I assume it would be transpiled to something similar
I can write it and use babel
see if it comes up with something better
I think it can transpile with TCO
the old function:
_traverse(obj, cb, context = '') {
        fns.forEachInObject(obj, (val, key) => {

            const path = context ? context + pathSplitter + key : key;
            const isObj = isObject(val);

            const shouldContinue = cb(val, key, path, obj, isObj);
            if (isObj && shouldContinue !== false) {
                // obj[key] instead of val to take changes as we traverse into account
                fns._traverse(obj[key], cb, path);
            }
        });
    },
hmm
I dunno if it can be done with the loop
oh I see it can
or not
err
 
Can you use recursion instead of forEachInObject?
 
I have to loop over the object
what would that look like
 
11:43 PM
hm, no
 
00:00 - 21:0021:00 - 00:00

« first day (2241 days earlier)      last day (2710 days later) »