ok thanks a lot for all this. I'll summarize it in a blog post for my
own recurring memory leaks :)
On Thu, Feb 19, 2009 at 3:20 AM, RobG wrote:
>
>
>
> On Feb 19, 10:56 am, Alexandre Plennevaux
> wrote:
>> thanks a lot. But why did they made it so complex? do we really need
>> the granularity
On Feb 19, 10:56 am, Alexandre Plennevaux
wrote:
> thanks a lot. But why did they made it so complex? do we really need
> the granularity to differenciate between "undefined", null, 0, "" and
> false ?
Yes, they are all have their uses in different circumstances.
For example, host methods lik
thanks a lot. But why did they made it so complex? do we really need
the granularity to differenciate between "undefined", null, 0, "" and
false ?
On Thu, Feb 19, 2009 at 1:51 AM, RobG wrote:
>
>
>
> On Feb 19, 9:44 am, Alexandre Plennevaux
> wrote:
>> thanks guys, so if i understand correctly,
On Feb 19, 9:44 am, Alexandre Plennevaux
wrote:
> thanks guys, so if i understand correctly, an unset property, if
> tested, returns "false". Correct ?
Strictly, no. It returns undefined, which may evaluate to false
depending on the test, which should be based on the possible values
and how t
@josh: it works superbly. Thanks a lot for this elegant solution !
On Thu, Feb 19, 2009 at 12:44 AM, Alexandre Plennevaux
wrote:
> thanks guys, so if i understand correctly, an unset property, if
> tested, returns "false". Correct ?
>
> On Wed, Feb 18, 2009 at 11:35 PM, mkmanning wrote:
>>
>> T
thanks guys, so if i understand correctly, an unset property, if
tested, returns "false". Correct ?
On Wed, Feb 18, 2009 at 11:35 PM, mkmanning wrote:
>
> The method that Josh posted is (in some people's opinion) the
> preferred method for assigning values, and is sometimes called the
> 'default
The method that Josh posted is (in some people's opinion) the
preferred method for assigning values, and is sometimes called the
'default pattern' for obvious reasons (the other common form is the
guard pattern &&). It, along with the ternary, is usually more
succinct than if/else, the latter bein
or simply if (!Obj.sortby) Obj.sortby = 'time'; it's a bit more
efficient. All of undefined, null, 0 or "" will evaluate to false,
there's no need to check for each of them.
Anyway, Alexandre, the ternary you posted should also work, there is
probably something else wrong in your code.
- ricardo
I think this might work, give it a try:
Obj.sortby = Obj.sortby || 'time';
-- Josh
-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf
Of Alexandre Plennevaux
Sent: Wednesday, February 18, 2009 9:07 AM
To: Jquery-en
Subject: [jQuery] defaul
9 matches
Mail list logo