Public Questions for tag [javascript-objects]

Ask Question

5 questions


0

Vote

3

Answers

69

View

const myObject = new Object(); myObject["firstname"] = "Gareth"; myObject["lastname"] = "Simpson"; myObject["age"] = 21;

Jan 29

0

Vote

4

Answers

34

View

I need to be able to merge two (very simple) JavaScript objects at runtime. For example I'd like to:var obj1 = { food: 'pizza', car: 'ford' } var obj2 = { animal: 'dog' } obj1.merge(obj2); //ob

Jan 29

0

Vote

3

Answers

56

View

I have an object x. I'd like to copy it as object y, such that changes to y do not modify x. I realized that copying objects derived from built-in JavaScript objects will result in extra, unwanted pro

Jan 16

0

Vote

4

Answers

31

View

After an AJAX request, sometimes my application may return an empty object, like:var a = {};How can I check whether that's the case?

Jan 13

0

Vote

4

Answers

59

View

What is the short and efficient way to find out if a JavaScript array contains a value?This is the only way I know to do it in JavaScript array:function contains(x, obj) { for (var i = 0; i < x

Jan 04