Problem with "hasOwnProperty" function

Does anyone have any idea what’s wrong with that?

let ItemsAmount = $w ( ‘#dsSampling’ ). getTotalCount ();
$w ( ‘#dsSampling’ ). getItems ( 0 , ItemsAmount )
. then ( ( result ) => {
let Items = result . items ;
for ( var i = 0 ; i < ItemsAmount ; i ++) {
if ( Items [i]. hasOwnProperty ( ‘relevantLimits’ ))
{
let ExceedingText = CompareToLimits ( Items [i], Items [i]. relevantLimits ,i);

It’s working, but I got this error :

I also tried to use the explicit Item like this:

let ItemsAmount = $w ( ‘#dsSampling’ ). getTotalCount ();
$w ( ‘#dsSampling’ ). getItems ( 0 , ItemsAmount )
. then ( ( result ) => {
let Items = result . items ;
for ( var i = 0 ; i < ItemsAmount ; i ++) {
$w ( ‘#dsSampling’ ). setCurrentItemIndex (i);
let Item = $w ( ‘#dsSampling’ ). getCurrentItem ();
if ( Item . hasOwnProperty ( ‘relevantLimits’ ))
{

But still got an error:

Any idea?

You are getting warnings and not errors. Is the code doing what you expect? If so, then nothing to worry about.

The “proper” way to call it is Object.prototype.hasOwnProperty(objectName, key), so in your case (assuming Item is the object), it would be

Object.prototype.hasOwnProperty(Item, "relevantLimits")

This warning is a safety warning, you can check the reason here: ES-Lint

Basically is a safeguard for injected code.