10 examples of 'javascript check if object exists' in JavaScript

Every line of 'javascript check if object exists' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
19function objectKeyExist(object)
20{
21 return _.some(object, function (o) {
22 return !_.isEmpty(_.pick(o, ['customer', 'cart']));
23 })
24}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

148export function hasObject(objectId:string):boolean {
149 return _registeredObjects.hasOwnProperty(objectId) &&
150 _registeredObjects[objectId] !== null;
151}
194function internalCheck(oObject) {
195 if (oObject.__publicControl) {
196 return true;
197 }
198 if (!oObject) {
199 return false;
200 }
201 var oParent = oObject.getParent();
202 if (!oParent) {
203 return false;
204 }
205 if (oParent.__publicControl) {
206 var aList = that.findAllPublicElements(oParent, oCore).filter(function(oSingleControl) {
207 return oSingleControl.getId() === oControl.getId();
208 });
209 return aList.length > 0;
210 }
211 return internalCheck(oParent);
212}
17function CheckExists(id) {
18 var idName = "assets/" + id.toLowerCase();
19 var idNoExt = idName.substring(0, idName.lastIndexOf("."));
20 return allFiles.hasOwnProperty(idName) || allAssets.hasOwnProperty(idNoExt);
21}
81function valueExists(value: any) {
82 return value != null;
83}
11function exists(val) { return val !== null && val !== undefined }
876export function checkObject(object: EezObject): IMessage[] {
877 if (isArray(object)) {
878 const check = object._propertyInfo!.check;
879 if (check) {
880 return check(object);
881 }
882 } else {
883 if ((object as any).check) {
884 return (object as any).check();
885 }
886 }
887 return [];
888}
13static checkFunctionsOfObject(object, functions) {
14 functions.forEach(func => {
15 assert.equal(!!object[func], true);
16 });
17}
1function jsCheck(id)
2{
3 el=document.getElementById(id);
4 el.checked='checked';
5}
248function exists(plc, isEndpoint) { //place, boolean indicator if this place will be the start or stop
249 for(var i=0; i<wayPoint.length; i++) { //loop through waypoints
250 if(wayPoint[i]['formatted_address'] == plc['formatted_address']) {
251 alert("Address:\n" + "'" + wayPoint[i]['formatted_address'] + "'\nis already a waypoint!\n");
252 return true;
253 }
254 }
255
256 //check that the potential waypoint isn't the same as the start or end
257 if(!isEndpoint && ((typeof start !='undefined' && start['formatted_address'] == plc['formatted_address']) || (typeof end !='undefined' && end['formatted_address'] == plc['formatted_address']))) {
258 alert("Address:\n" + "'" + plc['formatted_address'] + "'\nis your start or end point!\n");
259 return true;
260 }
261 return false; //working :D!
262
263}

Related snippets