To check if object properties are undefined

Asked 2 years ago, Updated 2 years ago, 94 views

What is the best way to check if object properties are undefined in JavaScript?

javascript object

2022-09-22 11:46

1 Answers

if (typeof something === "undefined") {
    alert("something is undefined");
}
f (typeof my_obj.someproperties === "undefined"){
    console.log('the property is not available...'); // print into console
}

It can be applied in this way.


2022-09-22 11:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.