Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Commonmark migration
Source Link

It's not recomended to extend Object.prototype, this will lead to strange behaviours and there is no need to do it one way if there is a less dangerous one like a simple function.

in_array(obj, [ 'a', 'b', 'c' ]);

You can even create a utils object

utils.in_array(obj, [ 'a', 'b', 'c' ]);

Once I've said that...

This looks very similar to Extending Object.prototype JavaScript and I totally agree with Alex Wayne:

I think it's fine if it works in your target environment.

Also I think prototype extension paranoia is overblown. As long as you use hasOwnProperty() like a good developer that it's all fine. Worst case, you overload that property elsewhere and lose the method. But that's your own fault if you do that.

It's not recomended to extend Object.prototype, this will lead to strange behaviours and there is no need to do it one way if there is a less dangerous one like a simple function.

in_array(obj, [ 'a', 'b', 'c' ]);

You can even create a utils object

utils.in_array(obj, [ 'a', 'b', 'c' ]);

Once I've said that...

This looks very similar to Extending Object.prototype JavaScript and I totally agree with Alex Wayne:

I think it's fine if it works in your target environment.

Also I think prototype extension paranoia is overblown. As long as you use hasOwnProperty() like a good developer that it's all fine. Worst case, you overload that property elsewhere and lose the method. But that's your own fault if you do that.

It's not recomended to extend Object.prototype, this will lead to strange behaviours and there is no need to do it one way if there is a less dangerous one like a simple function.

in_array(obj, [ 'a', 'b', 'c' ]);

You can even create a utils object

utils.in_array(obj, [ 'a', 'b', 'c' ]);

Once I've said that...

This looks very similar to Extending Object.prototype JavaScript and I totally agree with Alex Wayne:

I think it's fine if it works in your target environment.

Also I think prototype extension paranoia is overblown. As long as you use hasOwnProperty() like a good developer that it's all fine. Worst case, you overload that property elsewhere and lose the method. But that's your own fault if you do that.

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

It's not recomended to extend Object.prototype, this will lead to strange behaviours and there is no need to do it one way if there is a less dangerous one like a simple function.

in_array(obj, [ 'a', 'b', 'c' ]);

You can even create a utils object

utils.in_array(obj, [ 'a', 'b', 'c' ]);

Once I've said that...

This looks very similar to Extending Object.prototype JavaScript Extending Object.prototype JavaScript and I totally agree with Alex Wayne:

I think it's fine if it works in your target environment.

Also I think prototype extension paranoia is overblown. As long as you use hasOwnProperty() like a good developer that it's all fine. Worst case, you overload that property elsewhere and lose the method. But that's your own fault if you do that.

It's not recomended to extend Object.prototype, this will lead to strange behaviours and there is no need to do it one way if there is a less dangerous one like a simple function.

in_array(obj, [ 'a', 'b', 'c' ]);

You can even create a utils object

utils.in_array(obj, [ 'a', 'b', 'c' ]);

Once I've said that...

This looks very similar to Extending Object.prototype JavaScript and I totally agree with Alex Wayne:

I think it's fine if it works in your target environment.

Also I think prototype extension paranoia is overblown. As long as you use hasOwnProperty() like a good developer that it's all fine. Worst case, you overload that property elsewhere and lose the method. But that's your own fault if you do that.

It's not recomended to extend Object.prototype, this will lead to strange behaviours and there is no need to do it one way if there is a less dangerous one like a simple function.

in_array(obj, [ 'a', 'b', 'c' ]);

You can even create a utils object

utils.in_array(obj, [ 'a', 'b', 'c' ]);

Once I've said that...

This looks very similar to Extending Object.prototype JavaScript and I totally agree with Alex Wayne:

I think it's fine if it works in your target environment.

Also I think prototype extension paranoia is overblown. As long as you use hasOwnProperty() like a good developer that it's all fine. Worst case, you overload that property elsewhere and lose the method. But that's your own fault if you do that.

Source Link

It's not recomended to extend Object.prototype, this will lead to strange behaviours and there is no need to do it one way if there is a less dangerous one like a simple function.

in_array(obj, [ 'a', 'b', 'c' ]);

You can even create a utils object

utils.in_array(obj, [ 'a', 'b', 'c' ]);

Once I've said that...

This looks very similar to Extending Object.prototype JavaScript and I totally agree with Alex Wayne:

I think it's fine if it works in your target environment.

Also I think prototype extension paranoia is overblown. As long as you use hasOwnProperty() like a good developer that it's all fine. Worst case, you overload that property elsewhere and lose the method. But that's your own fault if you do that.

lang-js

AltStyle によって変換されたページ (->オリジナル) /