TreeviewCopyright © aleen42 all right reserved, powered by aleen42
Properties Back
1. Use dot notation
- To use dot notation when accessing properties.
- Eslint rules tags:
dot-notation
const Aleen = {
name: 'PuiMan Cheui',
age: '22'
};
/**
* bad
*/
const name = Aleen['name'];
/**
* good
*/
const name = Aleen.name;
2. Use subscript notation []
- To use subscript notation
[]
when accessing properties with a variable.
const Aleen = {
name: 'PuiMan Cheui',
age: '22'
};
function getProperty(prop) {
return Aleen[prop];
}
const name = getProperty('name');