admin管理员组文章数量:1332339
I am trying to debug some JQuery ajaxSetUp
behaviour. I set a timeout value and wish to see it set in the debugger. To do this I need to know what to watch while debugging. To investigate where the timeout is set, I do the following in a firefox console:
var obj = jQuery.ajaxSetup({
timeout: 120000
});
console.log("obj=" + obj.timeout)
I want to find out what type of object obj
is? I know JavaScript is dynamically typed but if I can find out what object it is then I know what to add a watch to when debugging.
I am trying to debug some JQuery ajaxSetUp
behaviour. I set a timeout value and wish to see it set in the debugger. To do this I need to know what to watch while debugging. To investigate where the timeout is set, I do the following in a firefox console:
var obj = jQuery.ajaxSetup({
timeout: 120000
});
console.log("obj=" + obj.timeout)
I want to find out what type of object obj
is? I know JavaScript is dynamically typed but if I can find out what object it is then I know what to add a watch to when debugging.
- You want to know that obj is really an object from ajax Setup? Not going to happen. – epascarello Commented Apr 29, 2013 at 14:07
5 Answers
Reset to default 3Type of obj
is object
. See:
typeof obj
// "object"
Also, the constructor is global javascript Object
. Here:
obj.constructor.name
// "Object"
jQuery has a few utility methods like .isArray()
, .isFunction()
, .isNumeric()
and .isPlainObject()
that return true or false. Use these one after the other to determine whether an object is of a specific type.
there is special function in jquery
jQuery.type(obj)
You can use the typeof
operator.
This wasn't a good approach for this problem. I looked at the JQuery source and saw when you invoke ajaxSetUp it updates the jQuery.ajaxSettings object.
So if you do...
console.log(jQuery.ajaxSettings.timeout)
in the debug console you'll get the value.
I am putting answer here in case it is use to anyone.
本文标签: jqueryFind out Object type in JavaScriptStack Overflow
版权声明:本文标题:jquery - Find out Object type in JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742333184a2455101.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论