Tagged Questions
17
votes
2answers
2k views
Array Like Objects in Javascript
I'm wondering how jQuery constructs it's array like object. The key thing I'm trying to work out is how it manages to get the console to interpret it as an array and display it as such. I know it has ...
77
votes
7answers
30k views
Create an empty object in JavaScript with {} or new Object()?
There are two different ways to create an empty object in JavaScript:
var objectA = {}
var objectB = new Object()
Is there any difference in how the script engine handles them? Is there any reason ...
12
votes
3answers
3k views
What are the differences between JSON and JavaScript object?
I am new to JSON and JavaScript object.
Can anyone please explain the differences between JSON and JavaScript object?
What are their uses?
Is one better than the other? or it depends on the ...
23
votes
7answers
23k views
Number of elements in a javascript object
Is there a way to get (from somewhere) the number of elements in a javascript object?? (i.e. constant-time complexity).
I cant find a property or method that retrieve that information. So far I can ...
-2
votes
3answers
1k views
how to return value from callback function
This question is asked many times in SO. But still I can't get stuff.
I want to get some value from callback.look at bellow script for clarification.
function foo(address){
// google map ...
11
votes
1answer
27k views
Encoding Javascript Object to Json string
I want to encode a javascript object into a json string and I am having considerable difficulties.
The Object looks something like this
new_tweets[k]['tweet_id'] = 98745521;
new_tweets[k]['user_id'] ...
4
votes
3answers
203 views
JavaScript “this” referce to wrong object
Well, this doesn't really refer to the wrong object, but I do not know how to refer to the correct one.
function someObj() {
this.someMethod1 = function() {
var elementBtn = ...
4
votes
5answers
6k views
jQuery create object from form fields
How can I create a object with a form's fields and values?
like this one:
{
fields:
{
name: 'foo',
email: '[email protected]',
comment: 'wqeqwtwqtqwtqwet'
}
}
assuming ...
11
votes
3answers
184 views
What is the behavior of typing {a:1} giving 1, and {a:1, b:2} giving an error in a Javascript console?
The following will show in Firebug or in jsconsole.com or in other Javascript interactive console:
>>> foo = { a : 1, b : 2.2 }
Object { a=1, more...}
>>> foo.a
1
>>> ...
7
votes
2answers
111 views
javascript methods that can not be called from jquery objects?
I was reading Learning jQuery 1.3 jonathan chaffer and karl swedberg and while sorting table , they used .get() before calling .sort(), and said we need to transform jqurey objects into array of DOM ...
0
votes
1answer
103 views
Access JavaScript Object Literal value in same object [duplicate]
Possible Duplicate:
Self-references in object literal declarations
Is there any way access the value of a property name in the same object literal? Something like this:
myFunction.init({
...
3
votes
1answer
2k views
using reserved words as property names, revisited
Can a reserved word be used as an object's property name?
This issue was raised in indirectly previous a stackoverflow question. the answer seemed general consensus by @Squeegy: You can use those ...
2
votes
7answers
459 views
Are Javascript arrays primitives? Strings? Objects?
I've been monkeying with Javascript for several years now (since back in the day before Gmail, Facebook, and YouTube, if you believe such a day existed). Big high-five to Thau.
My Question, as such:
...
1
vote
5answers
310 views
How does a jQuery instance appear as an array when called in console.log?
When entered into a JavaScript console, a jQuery object appears as an array. However, it's still an instance of the jQuery object.
var j = jQuery();
=> []
console.log(j);
=> []
...
5
votes
1answer
763 views
Advantage of using Object.create
Similar to, but different from this question. The code below is from JavaScript: The Definitive Guide. He's basically defining an inherit method that defers to Object.create if it exists, otherwise ...