javascript - Naming conventions - HTML elements in JS -
how name html element objects in js?
var diveditorarea = document.getelementbyid("editorarea");
var btnchecksyntax = document.getelementbyid("checksyntax");
is way?
to knowledge, there no convention naming html elements in js. javascript such diverse world if there convention, hardly followed majority of community. see, example, variety of code linters , code style conventions there (https://www.sitepoint.com/comparison-javascript-linting-tools/).
names should show intentions clearly, code understandable. don't think adding type of html element js variable names of use clarity purposes (the 'btn' , 'div' in example), there cases adds clarity. and, if in team, should follow team's conventions.
use best judgement , strive clarity in code.
Comments
Post a Comment