The issue is regarding building javascript objects and accessing properties
// Build JavaScript Object
var myDog = {//name,legs,tails and friends are properties of object "myDog"
name: "Hunter",
legs: 4,
tails: 1,
friends: ['Jordan', 'Sarina'] //getting error here
};
//Accessing object properties
let dogname = myDog.name; //using dot(.) notation
let friends = myDog['friends']; //using bracket notation
let accessObjProUsingVariableName = 'legs';
let dogleg = myDog[accessObjProUsingVariableName]; //using a variable
console.log('Doglegs :- ' + dogleg);
The above code snippet should run without any warnings or errors. Instead, I am getting errors.
The package(linter-jscs) suggests using dot notation instead of brackets or variable for member expressions.
Is this functionality removed in ES6 or I understood the warning incorrectly. I am using linter-jscs and linter-jshint.
I used online code editors, pycharm and it works. It would be good if my most fav editor 'Atom' can make it work. Here is one of the online editors that I used to demonstrate testing using object
I believe this is a serious issue as to do the testing using object then using dot notation the output that I am getting is 'undefined'
var lookup = {
alpha: 'Adams',
bravo: 'Boston',
foxtrot: 'Frank',
};
function checkObj(checkProp) {
if (lookup.hasOwnProperty(checkProp)) {
return lookup.checkProp;
} else {
return 'not found';
}
}
console.log('using object to test' + checkObj('alpha'));
Version
4.2.2
The issue is regarding building javascript objects and accessing properties
The above code snippet should run without any warnings or errors. Instead, I am getting errors. The package(linter-jscs) suggests using dot notation instead of brackets or variable for member expressions.
Is this functionality removed in ES6 or I understood the warning incorrectly. I am using linter-jscs and linter-jshint. I used online code editors, pycharm and it works. It would be good if my most fav editor 'Atom' can make it work. Here is one of the online editors that I used to demonstrate testing using object
I believe this is a serious issue as to do the testing using object then using dot notation the output that I am getting is 'undefined'
while if you use bracket notation it works.
Thanks in Advance!!