Linked Questions
68 questions linked to/from Check if a value is an object in JavaScript
66
votes
2
answers
39k
views
test if a variable is a primitive rather than an object? [duplicate]
Is it possible to test a variable to see if it is a primitive?
I have seen lots of questions about testing an variable to see if it is an object, but not testing for a primitive.
This question is ...
0
votes
2
answers
6k
views
jQuery.type() is deprecated. When checking if a var is not an object, what should I use instead? [duplicate]
jQuery.type() is deprecated in jQuery 3.3 and above. When refactoring older code that uses this API, what should I use instead of jQuery.type()?
For example, one of the plugins my page relies on uses ...
3
votes
0
answers
4k
views
Check if value is of primitive type in TypeScript [duplicate]
I have a method:
deepCopy (destination: any, source: any {...}
and I would like to check if the source is of any primitive type in ExtJS it would look like Ext.isPrimitive(source) but I can't find a ...
-1
votes
3
answers
2k
views
How to check whether a JSON object key is an object or string? [duplicate]
So right now, I created an example of a JSON object where:
var myObj = {
address: {
0: ["41 Lake Avenue"]
},
name: "jake"
}
myObj itself as a whole is a JSON ...
4
votes
4
answers
157
views
Check is object exists in property [duplicate]
I am trying to see if the property contains another object.
I have this:
{
"prop1": "value",
"prop2": "value",
"prop4": "value",
"prop5": {
"innerprop1": "value",
"innerprop2": "...
0
votes
1
answer
2k
views
checking if an element is an object in javascript [duplicate]
I am using the following code to check if an element is an object in javascript:
element.constructor == Object Is this a correct way or there are more appropriate ways
to check that? An alternate ...
0
votes
1
answer
1k
views
Read a jsonObject recursively in javascript [duplicate]
I am trying to read a nested object as a key-value. I am using a recursive function to be able to enter each object and print its key-value. The problem is when I try to read a key-value where the ...
0
votes
2
answers
731
views
How extract Object with "{ }" from an string [duplicate]
I try to extract Object from bellow array :
var array = [];
array =
a,b,c,{"A":"0","f":"1","g":"2"},{"B":"5","v":"8","x":"4"},{"C":"0","f":"1","g":"2"},c,b
imagine extract this :
result = [
{"A":"0"...
0
votes
1
answer
409
views
How to judge whether a value is Object Literal in JavaScript? [duplicate]
In my limited experience about object type judgment,I don't know how to judge whether a value is Object Literal in JavaScript? I am searching for a long time on net.But no use.Please help or try to ...
0
votes
1
answer
456
views
How can I detect ES5 object types in JavaScript? [duplicate]
According to the spec there are only 6 types, 5 of which are native ( Null, Undefined, Number, String, Boolean ) and 1 which is of type Object.
Googled it.
It appears that typeof fails for null and ...
0
votes
1
answer
78
views
JS distinguish between objects and primitives in array [duplicate]
I have an update method that should update an item in array:
function update(array) {
return array.map(item => {
// item or primitive?
})
}
What is the best way (in terms of reliability ...
5643
votes
47
answers
2.2m
views
Which equals operator (== vs ===) should be used in JavaScript comparisons?
I'm using JSLint to go through JavaScript, and it's returning many suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing idSele_UNVEHtype.value....
3143
votes
47
answers
3.1m
views
Is there a standard function to check for null, undefined, or blank variables in JavaScript? [duplicate]
Is there a universal JavaScript function that checks that a variable has a value and ensures that it's not undefined or null? I've got this code, but I'm not sure if it covers all cases:
function ...
1509
votes
28
answers
1.5m
views
Safely turning a JSON string into an object
Given a string of JSON data, how can I safely turn that string into a JavaScript object?
Obviously I can do this unsafely with something like:
var obj = eval("(" + json + ')');
but that leaves me ...
441
votes
11
answers
162k
views
Understanding the difference between Object.create() and new SomeFunction()
I recently stumbled upon the Object.create() method in JavaScript, and am trying to deduce how it is different from creating a new instance of an object with new SomeFunction(), and when you would ...