Crier: But won’t that make myProp available with undefiend
Teneyck: Or false in this case
Bolk: Z1mme: there is no shorthand for a compound condition
Harutunian: We need shorthands for EVERYTHING 😀
Mabee: Anyone work with amazon api
Hofheimer: Is it acceptable to use the object property lookup instead of iterating the array to find a value?
Reeter: I.e. var obj = { ‘hello’ : true }; obj’hello’; instead of var arr = ‘hello’ ; arr.indexOf’hello’;
Macrowski: Those are different data structures, depends on what you need
Tashima: To find if the value is within the data structure
Macrowski: If it is an object you probably want .hasOwnProperty
Slimak: With the object you’d do something like obj’hello’ !== undefined hello exists arr.indexOf’hello’ !== -1 hello exists
Sugden: Yes, i’m using hasOwnProperty
Tavernia: But i just feel like i’m doing something i’m not supposed to
Macrowski: What is the end goal?
Moro: Get repeated items in an array
Macrowski: Work with arrays then, not objects
Macrowski: You want to get duplicates?
Treinen: I can work with arrays too but
Hosier: It will be way slower
Macrowski: But that’s the data structure you have
Macrowski: Faster slower doesn’t matter if your algorithm isn’t working right
Houts: Anyone worked with amazon API?
Geasley: Yes, but i can use the object property lookup to build an object with keys that have the duplicated values
Ablin: Then i’ll just use Object.keys
Kassell: And get the array back
Macrowski: Manross, yes, but that is not a correct implementation
Macrowski: Manross, if you do that, then 1 == 1
Fritzpatrick: Django_: nope, you are first person ever
Ravelo: It’s merely for strings
Macrowski: Manross, dunno, I’d rather be general, and do the On2 that works with anything, that the On which only works with strings, and it is brittle
Macrowski: How large is your array?
Macrowski: Before optimizing for performance at the cost of correctness, I’d rather profile the code first, because most likely it doesn’t matter, and correctness matters more
Lagreca: I actually don’t know, somebody asked me how to do it
Ternes: And i actually came up with the On2 solution
Tauscher: Which someone said, was kind of inneficient for strings
Stahley: For an array of 10k, it took my algorithm 40 secs
Luxon: While the other one takes me 1.5 secs
Macrowski: Manross, that’s quite the difference. If your code needs it that’s fine, I’d just make sure to name the function appropiately, and indicate that it only takes strings
Macrowski: Or rather, arrays of strings
Kimple: You should be able to remove uniques in On*logn by sorting first. if you can guarantee its sorted you can do it in On time and O1 space
Kimple: But if you only need strings then yeah just use a lookup
Macrowski: With sorting though, you also need to be aware of the type
Macrowski: On2 solution is the most generic, but slowest
Kimple: Yeah. you’d need a comparator
Bautiste: How do you identify a div’s id in javascript ?
Steeg: Probably a frequent question but is there a way to erase elements in javascript arrays which does not leave the slot with “undefined” ?
Demonbreun: I could copy all the elements not to be erased into a new array, but that seems to be a horrible way to go about it
Jacquay: Macrowski: Yeah. that would do what I just described
Macrowski: Madsy, that is basically what filter does, it creates a new array