I have following datas:
var formFeilds={
'text': {
'T1':{'required':true,'min':25,'max':55},
'T2':{'required':true,'min':2,'max':5}
}
,'text2':5
};
function findObj(obj){
return key,itsobj
}
I want take text1, text2 Objects and their names and related objects. For example findObj(formFeilds) would return (text,formFeilds.text AND text2,5) also findObj(formFeilds.text) would return (T1,formFeilds.text.T1 AND T1,formFeilds.text.T2) I need check returned values are object or not in jquery
asked Mar 10, 2012 at 22:34
Huseyin
1,5472 gold badges26 silver badges40 bronze badges
1 Answer 1
I need check returned values are object or not in jquery
You can use the native Javascript typeof operator but keep in mind that almost everything is an object in JS except string|boolean|number|null|undefined.
answered Mar 10, 2012 at 22:39
elclanrs
94.2k21 gold badges137 silver badges171 bronze badges
Sign up to request clarification or add additional context in comments.
9 Comments
pimvdb
Caveat:
typeof thinks null is an object.elclanrs
Yeah, JS and its things...But that's the general rule of objects
pimvdb
@Huseyin: Yes,
formFeilds is an object isn't it?Huseyin
@pimvdb yes it is an object with multiple contents.
elclanrs
I don't know if this is what you're after but this quick example with your code gives me, predictably,
typeof formFields.text2 // Number so it works...jsfiddle.net/elclanrs/zPkPV |
lang-js
5is not an object.