How check if key exists

For example how I can check if key exist
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.2

Something like this:

const d  = declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.2", {path: Date.now()});
if (d.path)
  log("Param exists");

Thank you. One more question. If I clear ACS when reboot

clear(“Device”, Date.now());
clear(“InternetGatewayDevice”, Date.now());

and then I try create internet connection

declare(“InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.*”, null, {path: 2});

but in device exists connection so I would like to load the connection from device or delete connection from device and create new one. How I can make it?
Thanks.