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?
base.jsandui.jsin 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