I am writing an application on Windows on HTML / JS on the WinJS library on Visual Studio 2015.

The check for the absence of an object property does not work:

var schedule = { rasp: { ВТОРНИК: "Я есть!" } } if (schedule.rasp.ПОНЕДЕЛЬНИК) { console.log("объект есть"); } 
 <link href="https://cdnjs.cloudflare.com/ajax/libs/winjs/4.4.0/css/ui-light.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/winjs/4.4.0/js/ui.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/winjs/4.4.0/js/base.js"></script> 

Try without WinJS: the test works adequately and no errors causing the application crash occur:

 var schedule = { rasp: { ВТОРНИК: "Я есть!" } } if (schedule.rasp.ПОНЕДЕЛЬНИК) { console.log("объект есть"); } 

I tried it like this, but errors still crawl:

 var schedule = { rasp: { ВТОРНИК: "Я есть!" } } if (typeof(schedule.rasp.ПОНЕДЕЛЬНИК) != undefined && schedule.rasp.ПОНЕДЕЛЬНИК) { console.log("объект есть"); } 
 <link href="https://cdnjs.cloudflare.com/ajax/libs/winjs/4.4.0/css/ui-light.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/winjs/4.4.0/js/ui.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/winjs/4.4.0/js/base.js"></script> 

What to do and how to fix?

  • I fixed the position of base.js and ui.js in snippets (the script wrote an error because of this) Obviously this is the error, first you need to link the main script, then the additional one. Maybe this is your problem? - Crantisz
  • Roll back edit. - Crantisz
  • @Crantisz is not the error. See screenshot . Browsers handle the condition normally, and the Visual Studio interpreter (Chakra engine) swears. - Kenya-West

1 answer 1

This does not seem to be a mistake, but a warning.

Will handle the exception soon

and below

If there is a handler, then everything will work.

Uncheck the checkbox in the message and you will be happy

  • One hell, the library throws an exception, even if I continue executing the code and even if I add an else {} to the condition. Just one more window pops up: Необработанное исключение в строке 4, столбце 318 в eval code. 0x800a138f - JavaScript runtime error: Unable to get property 'ПОНЕДЕЛЬНИК' of undefined or null reference Необработанное исключение в строке 4, столбце 318 в eval code. 0x800a138f - JavaScript runtime error: Unable to get property 'ПОНЕДЕЛЬНИК' of undefined or null reference . The most important thing is that the code is executed normally in browsers, and it is as if the property must be present in the application, and nothing else. - Kenya-West
  • try...catch doesn't help either - Kenya-West
  • @ Kenya-West And if the property is written in Latin? - Anton Shchyrov
  • The idea is that the server produces the Cyrillic alphabet ... Well, you have to suffer and replace the properties with the Latin alphabet. On the results the other day I will write. - Kenya-West
  • @Kenya-west just check. Maybe the assumption is wrong - Anton Shchyrov