Linked Questions
28 questions linked to/from Difference between using bracket (`[]`) and dot (`.`) notation
505 votes
16 answers
208k views
JavaScript property access: dot notation vs. brackets?
Other than the obvious fact that the first form could use a variable and not just a string literal, is there any reason to use one over the other, and if so under which cases? In code: // Given: var ...
1 vote
3 answers
2k views
How to access object value with ( ) parentheses in name? [duplicate]
Hi I have an object that I have filled from data in a CSV file. One of my ids is called "Disk_Usage(MB)" I try using my object.Disk_Usage(MB) but receive an error because javascript thinks disk ...
-1 votes
2 answers
64 views
.(dot) vs [ ] property assignment result differs for copied object [duplicate]
I have stumbled upon something that bugs me. I had to copy one object so I have written a helper function for that task. function deepCopy2(target, obj) { for (var prop in obj) { if (obj....
0 votes
1 answer
72 views
javascript object delete element [duplicate]
I have a question about delete object propery,for examble: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>test</title> </...
0 votes
0 answers
53 views
What is the difference between blog.title and blog[title]? [duplicate]
Assume blog is my object/array. Is one defined for objects and one for arrays? What is the fundamental difference between them and where do I use which one?
0 votes
0 answers
39 views
Is there any ways to make this code shorter to return object? [duplicate]
I want to make this code shorter. const coupons = rets.map((ret) => ({ coupon_id: ret.coupon_id, bot_id: ret.bot_id, lang_cd: ret.lang_cd, coupon_name: ret.coupon_name, start_date: ret....
0 votes
0 answers
20 views
Adding prev to linked list [duplicate]
Trying to solve a problem with linked lists requiring the conversion of a singly linked list into doubly linked list. I'm definitely missing some syntax to do this but I haven't been able to figure ...
653 votes
14 answers
380k views
What characters are valid for JavaScript variable names?
Which characters can be used for naming a JavaScript variable? I want to create a small "extension library" for my non-JavaScript users here at work (who all seem to be squeamish when it comes to the ...
6 votes
5 answers
11k views
Why javascript array element can't be accessed with dot notation?
Why it's not possible to access to array element with dot notation? var arr = ['Apple', 'Mango', 'Pineapple', 'Orange', {name: 'Banana', color: 'yellow'}]; console.log( arr[0] ); // "Apple" console....
1 vote
1 answer
3k views
Get Json From php file
I am new to jQuery. I have got an error when I try to get data from fileresult.php. fileresult.php $return_arr = array(); $row_array['status'] = 'Ok'; $row_array['message'] = 'good' array_push($...
0 votes
2 answers
2k views
coffeescript: get the value of an object's property starting with '@' symbol
How can I get the value of a object in coffeescript: {text="mytext", @name="Jon"} object.text works great but can`t get object.@name and is a 3party api json object (ebay api for example use a ...
0 votes
3 answers
1k views
Angular - how to concat var name
I just started to learn Angular, and I tried to make concat var name so I can control it dynamically. This is what I tried - <div ng-app="myApp" ng-controller="myCtrl"> <button ng-click="...
1 vote
3 answers
73 views
JQuery: Object value
Let a = {a: 1, b:2}, whichs shows in console Object {a: 1, b: 2}. When I do a.a I get 1. When I do a[a] I get undefined. Is it normal ? I'm asking this because I need to get values from dynamic ...
0 votes
6 answers
98 views
Use ["sort"](0) to call a function sort?
Can someone explain to me why this code is working ? [1,4,5,6,7,2,3]["sort"](0); //[1, 2, 3, 4, 5, 6, 7] I'm not quite understanding the syntax here. Meanwhile, why can't I use like this to choose ...
3 votes
1 answer
521 views
Difference between "foo.bar" and "foo['bar']" in js
I have to make sense of a codebase I was given on my new job. I can see many anti-patterns here, one of them is a "god object", which contains a lot of things and different object access it all the ...