Skip to content

Instantly share code, notes, and snippets.

@azizshamim
Last active December 10, 2015 00:19
Show Gist options
  • Save azizshamim/4350784 to your computer and use it in GitHub Desktop.
Save azizshamim/4350784 to your computer and use it in GitHub Desktop.
Javascript funniness
> var foo = []
undefined
> foo
[]
> foo['bar'] = 'baz'
'baz'
> foo
[ bar: 'baz' ]
>
> var foo = new Array();
undefined
> foo[0] = 'bar'
'bar'
> foo
[ 'bar' ]
> foo ['bar'] = 'baz'
'baz'
> foo['bar'] = 'baz'
'baz'
> foo
[ 'bar', bar: 'baz' ]
> JSON.stringify(foo)
'["bar"]'
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment