Andrey (azangru) wrote,
Andrey
azangru

У Гугла есть JavaScript style guide.

В котором, в частности, имеется такой пункт:

Associative Arrays
Never use Array as a map/hash/associative array
Associative Arrays are not allowed... or more precisely you are not allowed to use non number indexes for arrays. If you need a map/hash use Object instead of Array in these cases because the features that you want are actually features of Object and not of Array. Array just happens to extend Object (like any other object in JS and therefore you might as well have used Date, RegExp or String).
(link)

Я сначала удивился: мол, ни фига себе что бывает — кто-то использует arrays как objects / hash tables. Потом до меня дошло, что это, наверное, кто-то тянет свои привычки из других языков. Из каких, интересно? Из PHP?
Subscribe

  • (no subject)

    Also, Google's documentation style guide. With the latest trends about the correct language, obvi. This one via HN.

  • (no subject)

    Google's document on how they build Chrome dev tools with web components. And yeah, it includes a special dance for some semblance of type safety,…

  • (no subject)

    On the ideology in the industry: A guest on a podcast: There was a thread on Twitter the other day, with Adam Rackis, and he had made a comment…

  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments