This question already has answers here:
How can I access object properties containing special characters?
(2 answers)
Closed 8 years ago.
I have an object which looks like this:
{"response":{"mydata":[{"xxx:id":"8c8b9703-bc87-40d8-b8d7-f71ebff4002a","Description":"Tsameple desc"].....
Now, my question is, How do I access the Id field?
I have tried
$.response.mydata[i].xxx:id
However, this is resulting in an error thanks to the ":" in the key value. Any tips on how I can get the value?
Use the bracket notation :
response.mydata[i]['xxx:id']
Related
This question already has answers here:
Easy way to turn JavaScript array into comma-separated list?
(22 answers)
Closed 2 years ago.
Code:
let myClassFellows=[ ['Noor',1],['Jawaria',2]];
console.log(myClassFellows[0]);
Below is the output I want to show without the square brackets
What do you mean without square brackets? Like 'Noor', 1?
If so, you need to concatenate it into a string with myClassFellows[0].join(', ').
This question already has answers here:
How can I convert a comma-separated string to an array?
(19 answers)
Closed 2 years ago.
I have a problem, but I don't know how to solve it.
I got a handful of words from Cookies.get, separated by commas. Like this: apple,pineapple,tomato How can I put these words into an array?
Thank you very much.
Use the split method. Ex. words.split(","). Documentation here.
This question already has answers here:
What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wat' talk for CodeMash 2012?
(5 answers)
Objects and arrays addition
(4 answers)
Closed 3 years ago.
Why is the result of the expression {}+[] 0?
It appears that the + is treated as a unary operator instead of a normal addition operator. The expression then becomes {}0. Why is this valid JavaScript and why is the result 0? Why is the object literal in the expression ({})+[] treated normally?
Note: I tried searching for a similar question in SO but it doesn't look like searching using symbols works.
This question already has answers here:
Calling member function of number literal
(3 answers)
Closed 6 years ago.
toString() doesn't work on numeric literal like 5.toString(), but it works on string literal ("str".toString()) or after the numeric literal is assigned to var, like var a = 5;a.toString(). Wondering why it doesn't work for the first case?
You can do this if you wrap it in parenthesis.
(5).toString();
The first dot is the decimal mark. You need a second one to access the property:
5..toString();
This question already has answers here:
JavaScript property access: dot notation vs. brackets?
(17 answers)
Closed 8 years ago.
I didn't know that this is possible in JavaScript:
var test = {
"hello world": function(){
console.log('test');
}
};
Of course this is only a theoretical question:
Is there a possible way to call the hello world function other than test["hello world"]()?
Would it be possible to call it with the . operator?
Sorry but if key is has some special character then you cannot call this with '.' operator.
only way to call is bracket notation which you already know