Skip to content

Instantly share code, notes, and snippets.

@meandavejustice
Created December 17, 2013 00:21
Show Gist options
  • Save meandavejustice/7997704 to your computer and use it in GitHub Desktop.
Save meandavejustice/7997704 to your computer and use it in GitHub Desktop.
create arr, add an attribute with dot notation. wat?
> var arr = []
undefined
> arr
[]
> arr.keyName = true
true
> arr
[ keyName: true ]
> arr[0]
undefined
> arr.keyName
true
>
@junosuarez
Copy link

which line in particular is confusing or unexpected?

@taterbase
Copy link

Arrays are just special Object/Hash's. typeof arr holds the truth.

@meandavejustice
Copy link
Author

@jden I understand why it works... I was just having trouble understanding a use case.

@junosuarez
Copy link

I use it, eg, for paged collections. JavaScript collections, especially <ES6, are fairly assumption-rich and feature-poor compared to other languages, imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment