On Wed, Jan 4, 2012 at 7:42 AM, Daniel Friesen <li...@nadir-seen-fire.com>wrote:

> On Tue, 03 Jan 2012 06:14:36 -0800, Antoine Musso <hashar+...@free.fr>
> wrote:
>
> > Le Fri, 30 Dec 2011 18:31:30 +0100, Krinkle <krinklem...@gmail.com> a
> > écrit:
> >> Since virtually any value other than null and undefined is an object,
> >> including numbers, strings and functions.
> >
> > Much like ruby!   http://ruby-doc.org/core/Integer.html
> >
> >    $ irb
> >    >> 5.upto( 10 ) { |num| print "#{num}ber," }
> >    5ber,6ber,7ber,8ber,9ber,10ber,=> 5
> >    >> print 4.even?
> >    true=> nil
> >    >>
> >
> > You can change the 'even?' behavior to do something else of course :D
> >
> >
>
> ;) Oh no, in Ruby EVERYTHING is an object, there is no 'virtually' or
> 'almost'.
>
> >> nil.class
> => NilClass
> >> puts "nil is nil" if nil.nil?
> nil is nil
> => nil
> >> nil.is_a? NilClass
> => true
>
> Although, their booleans are awkward.
> >> true.class
> => TrueClass
> >> false.class
> => FalseClass
> >> true.class.superclass
> => Object
> >> false.class.superclass
> => Object
> Last I checked the way to say "Is this a boolean?" in Ruby was `value ===
> true || value === false`. Ugh.
>
> In JavaScript we have Boolean instead.
>
> --
> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
>

JavaScript:

>> true.constructor
< Boolean()

and Boolean inherits from Object too.

Difference though is that in constrary to Array and Object, JavaScript
treats a literal
strings, numbers and booleans always strictly equal to a similar one.

In that 5 === 5. Wheares new Number(5) === new Number(5) is false.

So eventhough numbers, strings and booleans are objects, they do not have
"typeof"
object, only those that are declared object through "typeof" are compared
by reference.

So both [1, 2] === [1, 2] and new Array(1,2) === new Array(1,2) is false.

yay!
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to