|
qntm posted:yup i guess, but why would you ever use it for anything?
|
# ? Nov 11, 2014 22:03 |
|
|
# ? Jun 12, 2024 04:55 |
|
okay, i looked at the mdn documentation and it is completely useless. it has no useful methods (toSource, toString, valueOf).
|
# ? Nov 11, 2014 22:07 |
|
Wheany posted:okay, i looked at the mdn documentation and it is completely useless. it has no useful methods (toSource, toString, valueOf). it has length, which is always 1!
|
# ? Nov 11, 2014 22:08 |
|
I don't think Boolean is supposed to be a class or anything, it's just a function that converts your poo poo to true or false. the fact that you can use new with Boolean is just how new works (like garbage)
|
# ? Nov 11, 2014 22:11 |
|
just use !!
|
# ? Nov 11, 2014 22:26 |
|
Wheany posted:i guess, but why would you ever use it for anything? you wouldn't, and you shouldn't, ever. the whole class shouldn't exist and if the word "Boolean" appears in someone's source then that person is living in a state of sin
|
# ? Nov 11, 2014 22:37 |
|
Symbolic Butt posted:javascript's new operator is stupid as heck I didn't realize this was a thing (or at least have the slightest inkling of what it did) now I do and i'm less happy for it thanks js
|
# ? Nov 11, 2014 22:43 |
|
Boolean is there so that you can box boolean values in places where you need an object, just like in Java. Adding ad-hoc properties, for example, in the JS case; storing in a pre-generics collection in Java. Boolean.prototype.valueOf could have automatically unboxed, but I'm not sure that magic would have been better. (Boolean.length is the length property that all functions have, it's not a property of the prototype.)
|
# ? Nov 11, 2014 23:33 |
|
Subjunctive posted:Boolean is there so that you can box boolean values in places where you need an object, just like in Java. Adding ad-hoc properties, for example, in the JS case; storing in a pre-generics collection in Java. boxing of primitives is a horrible feature that shouldn't exist
|
# ? Nov 12, 2014 00:16 |
|
hepatizon posted:primitives is a horrible feature that shouldn't exist
|
# ? Nov 12, 2014 01:02 |
|
in memory managed langs anyway
|
# ? Nov 12, 2014 01:03 |
|
just gonna leave this here: https://www.destroyallsoftware.com/talks/wat fun starts at 1:20
|
# ? Nov 12, 2014 01:15 |
|
DimpledChad posted:just gonna leave this here: https://www.destroyallsoftware.com/talks/wat im the people in the background that dont know how to laugh like people
|
# ? Nov 12, 2014 01:24 |
|
huh, rewatching that talk for the first time since I've gotten "decent" at javascript (aka DEHUMANIZE YOURSELF AND FACE TO PROTOTYPES), and I think he actually gets something wrong. he seems to say that this: is an object, but it's not; it's a string: which is, of course, also stupid, because javascript. it is at least one of the few implicit conversations in that talk that you can actually puzzle your way through ([] gets toString() cast on it for "", {} gets toString() called on it for "[object Object]", and they're concatenated) javascript's handling of operators and type conversion is, afaik, the worst in any common language outside of maybe php, and my least favorite thing about the language
|
# ? Nov 12, 2014 01:45 |
|
IIRC the + 1 vs -1 trick is just because javascript overloads the + operator to be usable for string concatenation, which really isn't uncommon though it is certainly confusing as gently caress when you're working with dynamic vars What I'm saying is lol if you never tried to do a string-> numeric conversion in js using (somevar+0), spent an hour figuring out why that didn't work, then smugly changed it to (somevar-0) and called it a day. Number() is for wusses TheresNoThyme fucked around with this message at 01:59 on Nov 12, 2014 |
# ? Nov 12, 2014 01:56 |
|
{} undefined a = {} Object {} a + [] "[object Object]" {} + [] 0
|
# ? Nov 12, 2014 02:09 |
|
TheresNoThyme posted:IIRC the + 1 vs -1 trick is just because javascript overloads the + operator to be usable for string concatenation, which really isn't uncommon though it is certainly confusing as gently caress when you're working with dynamic vars "1" + "1" == "11" is totally fine. 1 + "1" == "11" is not. I think even PHP makes more sense with both being 2 if you think of the + operator as a numbers thing.
|
# ? Nov 12, 2014 03:49 |
|
Symbolic Butt posted:"1" + "1" == "11" is totally fine. you're right, the second should be a type error
|
# ? Nov 12, 2014 04:17 |
|
And the first is false because they are different string objects
|
# ? Nov 12, 2014 04:31 |
|
anyone who talks about "objects of class Boolean" in js has no loving clue how it works and is not qualified to say how good or bad it is
|
# ? Nov 12, 2014 04:36 |
|
Tiny Bug Child posted:anyone who talks about "objects of class Boolean" in js has no loving clue how it works and is not qualified to say how good or bad it is you can do `new Boolean(true)`. you shouldn't, but you can, and that is an object of class Boolean (unless you're going to get really pedantic about "an object with prototype Foo" not being the same as "an object of class Foo" but then gently caress you)
|
# ? Nov 12, 2014 04:44 |
|
https://pachyderm-io.github.io/pfs/ i found this funny, maybe someone else here will too quote:Pachyderm will eventually be a complete replacement for Hadoop, built on top of a modern toolchain instead of the JVM. Hadoop is a mature ecosystem, so there's a long way to go before pfs will fully match its feature set. However, thanks to innovative tools like btrfs, Docker, and CoreOS, we can build an order of magnitude more functionality with much less code. quote:Rather than calling a map method on a class, Pachyderm POSTs files to the /map route on a webserver. This completely democratizes MapReduce by decoupling it from a single platform, such as the JVM. hey btrfs has some cool features, you could easily make a distributed system by gluing some exec calls and http on top of that, right? in fact lets replace YARN, HDFS and MapReduce all at once, to make it a full weekend project and instead of hard things like stdin/stdout let's democratize it by using something all programmers know how to write... web servers
|
# ? Nov 12, 2014 04:48 |
|
classes are *not* the same as prototypes. this is not a trivial distinction. js does not have classes and expecting prototypes to work like classes is basically the root of every moronic UGH JS INHERITANCE IS SO BAD complaint there is, so gently caress you for helping to propagate that misconception
|
# ? Nov 12, 2014 04:48 |
|
Tiny Bug Child posted:classes are *not* the same as prototypes. this is not a trivial distinction. js does not have classes and expecting prototypes to work like classes is basically the root of every moronic UGH JS INHERITANCE IS SO BAD complaint there is, so gently caress you for helping to propagate that misconception javascript is bad
|
# ? Nov 12, 2014 04:50 |
|
seriously don't know how you are such a goddamn web hipster that you're tweeting about whatever this week's hot new js framework is every day but you still manage to say something as dumb asabraham linksys posted:(unless you're going to get really pedantic about "an object with prototype Foo" not being the same as "an object of class Foo" but then gently caress you)
|
# ? Nov 12, 2014 04:51 |
|
i dont really understand js but i like how you can pass around functions and i like how the fact it has very little support for including or importing or whatever makes your language feel pretty stable
|
# ? Nov 12, 2014 04:53 |
|
it's almost like all those dumb loving frameworks hide the operation of the actual language from you just to replace it with a worse language that has no application outside the framework
|
# ? Nov 12, 2014 04:53 |
|
woah tbc turning abraham linksys into tiny bug bitch itt
|
# ? Nov 12, 2014 04:53 |
|
Tiny Bug Child posted:it's almost like all those dumb loving frameworks hide the operation of the actual language from you just to replace it with a worse language that has no application outside the framework
|
# ? Nov 12, 2014 04:55 |
|
i also like whatever language feature makes callbacks very natural for js. maybe it's closures or something. idk. maybe it's also the fact that it's only legitimate use is for ajaxy stuff.
|
# ? Nov 12, 2014 04:55 |
|
what about Number() vs parseInt()
|
# ? Nov 12, 2014 04:55 |
|
Tiny Bug Child posted:classes are *not* the same as prototypes. this is not a trivial distinction. js does not have classes and expecting prototypes to work like classes is basically the root of every moronic UGH JS INHERITANCE IS SO BAD complaint there is, so gently caress you for helping to propagate that misconception es6: The Boolean constructor is designed to be subclassable. It may be used as the value of an extends clause of a class declaration. Subclass constructors that intended to inherit the specified Boolean behaviour must include a super call to the Boolean constructor to initialize the [[BooleanData]] state of subclass instances. when the people who make the languages don't see the need to distinguish between a prototypical constructor and a subclassable constructor, I don't think it's bad to call it a class, man (also for funsies, though I don't think it has any real merit in this discussion: in es5, The [[Class]] internal property of the newly constructed Boolean object is set to "Boolean".)
|
# ? Nov 12, 2014 04:55 |
|
js has problems but not having class-based oop isn't one of them.
|
# ? Nov 12, 2014 04:56 |
|
MALE SHOEGAZE posted:i also like whatever language feature makes callbacks very natural for js. maybe it's closures or something. idk. maybe it's also the fact that it's only legitimate use is for ajaxy stuff. nah closures own outside of ajaxy stuff and callback hell when you realize that you can have generic looking functions that allow you to pass objects and the callbacks that handle them correctly in and get the same data out every time
|
# ? Nov 12, 2014 04:57 |
|
Blinkz0rz posted:what about Number() vs parseInt() parseInt("99abcdefg10456") => 99 not even once
|
# ? Nov 12, 2014 05:02 |
|
my #1 problem with working with javascript in the real world is that i find myself wanting to write c style ifdef poo poo in order to stop js assets from being downloaded over and over again this is most certainly due to a total misunderstanding on my part as to how javascript and programming and the internet in general work
|
# ? Nov 12, 2014 05:03 |
|
ecmascript 6 or whatever it is has classes, sure. it has an actual class keyword that's not just a reserved word for no apparent reason. but that is not javascript, that is a language that currently does not really exist the class property thing doesn't count either and i would be really surprised if that had any cross-browser compatibility
|
# ? Nov 12, 2014 05:04 |
|
fidel sarcastro posted:js has problems but not having class-based oop isn't one of them. it kinda is a problem when they aped java syntax and actually only got prototypal inheritance right in es5
|
# ? Nov 12, 2014 05:05 |
|
Blinkz0rz posted:nah closures own outside of ajaxy stuff and callback hell when you realize that you can have generic looking functions that allow you to pass objects and the callbacks that handle them correctly in and get the same data out every time oh yeah i meant that callbacks are natural for js because js is 99% of the time used for ajaxey poo poo. the closure thing was a separate drunk thought
|
# ? Nov 12, 2014 05:05 |
|
|
# ? Jun 12, 2024 04:55 |
|
fidel sarcastro posted:js has problems but not having class-based oop isn't one of them. it's getting the "classical sugar over prototypes" several frameworks (backbone, ember, ampersand-model, winjs, et al) and libraries already implement in ad-hoc fashion https://github.com/lukehoban/es6features#classes TheresNoThyme posted:parseInt("99abcdefg10456") => 99 code:
|
# ? Nov 12, 2014 05:06 |