["scrolling"] is better written in dot notation.
220
221 if (opt.type === 'html') {
222 opt.attr['frameborder'] = '0'
223 opt.attr['scrolling'] = 'no'224 }
225
226 var d = document.createElement(tag)
["frameborder"] is better written in dot notation.
219 return warn('visit_count: unknown type: ' + opt.type)
220
221 if (opt.type === 'html') {
222 opt.attr['frameborder'] = '0'223 opt.attr['scrolling'] = 'no'
224 }
225
["src"] is better written in dot notation.
212 if (opt.no_branding) opt.attr['src'] += '&no_branding=1'
213 if (opt.style) opt.attr['src'] += '&style=' + enc(opt.style)
214 if (opt.start) opt.attr['src'] += '&start=' + enc(opt.start)
215 if (opt.end) opt.attr['src'] += '&end=' + enc(opt.end)216
217 var tag = {png: 'img', svg: 'img', html: 'iframe'}[opt.type]
218 if (!tag)
["src"] is better written in dot notation.
211 opt.attr['src'] = get_endpoint() + 'er/' + enc(opt.path) + '.' + enc(opt.type) + '?'
212 if (opt.no_branding) opt.attr['src'] += '&no_branding=1'
213 if (opt.style) opt.attr['src'] += '&style=' + enc(opt.style)
214 if (opt.start) opt.attr['src'] += '&start=' + enc(opt.start)215 if (opt.end) opt.attr['src'] += '&end=' + enc(opt.end)
216
217 var tag = {png: 'img', svg: 'img', html: 'iframe'}[opt.type]
["src"] is better written in dot notation.
210
211 opt.attr['src'] = get_endpoint() + 'er/' + enc(opt.path) + '.' + enc(opt.type) + '?'
212 if (opt.no_branding) opt.attr['src'] += '&no_branding=1'
213 if (opt.style) opt.attr['src'] += '&style=' + enc(opt.style)214 if (opt.start) opt.attr['src'] += '&start=' + enc(opt.start)
215 if (opt.end) opt.attr['src'] += '&end=' + enc(opt.end)
216
["src"] is better written in dot notation.
209 opt.attr = opt.attr || {width: '200', height: (opt.no_branding ? '60' : '80')}
210
211 opt.attr['src'] = get_endpoint() + 'er/' + enc(opt.path) + '.' + enc(opt.type) + '?'
212 if (opt.no_branding) opt.attr['src'] += '&no_branding=1'213 if (opt.style) opt.attr['src'] += '&style=' + enc(opt.style)
214 if (opt.start) opt.attr['src'] += '&start=' + enc(opt.start)
215 if (opt.end) opt.attr['src'] += '&end=' + enc(opt.end)
["src"] is better written in dot notation.
208 opt.path = opt.path || get_path()
209 opt.attr = opt.attr || {width: '200', height: (opt.no_branding ? '60' : '80')}
210
211 opt.attr['src'] = get_endpoint() + 'er/' + enc(opt.path) + '.' + enc(opt.type) + '?'212 if (opt.no_branding) opt.attr['src'] += '&no_branding=1'
213 if (opt.style) opt.attr['src'] += '&style=' + enc(opt.style)
214 if (opt.start) opt.attr['src'] += '&start=' + enc(opt.start)
Description
In JavaScript, there are two ways to access the properties of an object:
- dot-notation
(object.property)
( Recommended ) - square-bracket notation
(object["property"])
( Bad Practice )
The dot notation is preferred because it is easier to read, less verbose, and works better with aggressive JavaScript minimizers.
Bad Practice
const x = object["property"];
Recommended
const x = object.property;
x = object[y];