Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to use "id" as a property name?

Tags:

People also ask

What is the use of id property?

The id attribute is used to point to a specific style declaration in a style sheet. It is also used by JavaScript to access and manipulate the element with the specific id. The syntax for id is: write a hash character (#), followed by an id name. Then, define the CSS properties within curly braces {}.

Is id an attribute or property?

id is a pure reflected property, it doesn't modify or limit the value. The type property is a reflected property for the type attribute: Getting the property reads the attribute value, and setting the property writes the attribute value.

What is difference between id and name?

The ID of a form input element has nothing to do with the data contained within the element. IDs are for hooking the element with JavaScript and CSS. The name attribute, however, is used in the HTTP request sent by your browser to the server as a variable name associated with the data contained in the value attribute.

Can id and name be the same?

Yup! This is absolutely fine. name is used during form submission to POST/GET the values.


I created an object with an "id" property (it's coming from a database with unique ids). Then I remembered that "id" is a class name in Cocoa. There didn't seem to be any issue with using an int property named "id", but will I run into problems later?