Skip to content

Conversation

@treywood
Copy link
Contributor

Where possible (other than IE 8), use Object.defineProperty to extend the String prototype so that the linkify function is not enumerable on String instances.

This causes iteration over a string to behave correctly:

for (i in "test") { console.log(i); }
>> 0
>> 1
>> 2
>> 3

By only appending the property to the prototype (String.prototype.linkify = ...), you get:

for (i in "test") { console.log(i); }
>> 0
>> 1
>> 2
>> 3
>> linkify

Copy link
Owner

@nfrasser nfrasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nfrasser nfrasser merged commit 95333da into nfrasser:master Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants