The simplest way, but this approach only works if you are sure that the values of test.test and test.test2 are not falsy (i.e., not 0, null, undefined, false, NaN, or an empty string ''). If you need to ensure the properties simply exist and can hold any value (including falsy values), you should use a different approach.
Source code viewer
const test = { test: 'value1', test2: 'value2' }; if (test.test && test.test2) { console.log("Both 'test' and 'test2' exist and are truthy"); } else { console.log("One or both parameters do not exist or are not truthy"); }Programming Language: ECMAScript