


JS naming convention: Hungarian nomenclature or camel case nomenclature
JS Naming Standards
Naming standards are necessary to enhance the readability of the code. You can understand the meaning at a glance. Standards are in compliance with Rules make the code conducive to later maintenance and can also greatly improve development efficiency. A normal website has a lot of JS code. If you don’t follow certain rules during the writing process, you won’t be able to understand what you wrote later. This is a very troublesome thing, so you should write it in your usual time. During the practice, develop good coding habits.
Generally Hungarian nomenclature or camel case nomenclature is used.
The principle of Hungarian nomenclature: variable name = attribute + type + object description. His key is: prefix with one or more lowercase letters, followed by one or more words with an initial capital letter, which specifies the purpose of the variable.
The principle of camel case naming: the first word starts with a lowercase letter, and the first letter of each subsequent word is capitalized. For example: myFirstName, myLastName. Such variable names look like camels rising one after another, hence the name. The key to the camel case method is: except for the first word, the size of the first letters of other words, a mixture of uppercase and lowercase letters to form variable names and function names, and underscores can also be used to form logical breakpoints, which can enhance the readability of the code. .
What kind of naming convention to use depends on personal preference or company regulations. Note: When naming, you cannot use reserved words or names that are too long and difficult to remember. Avoid using two similar variable names. The following are some commonly used Hungarian nomenclature prefixes:
Type | Prefix | Type | Example |
Array | a | Array | aItems(item) |
String | s | String | sUserName |
Function | fn | Function | fnHandler(Handler) |
Object | o | Object | op |
Integer | i | Integer | iItemCount(item count) |
Floating point number | f | Float | fPrice(Price) |
Boolean | b | Boolean | bIsComplete(Complete) |
Regular Expression | re | RegExp | reEmailCheck(Email Detection) |
The above is the detailed content of JS naming convention: Hungarian nomenclature or camel case nomenclature. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

This post compiles helpful cheat sheets, reference guides, quick recipes, and code snippets for Android, Blackberry, and iPhone app development. No developer should be without them! Touch Gesture Reference Guide (PDF) A valuable resource for desig

jQuery is a great JavaScript framework. However, as with any library, sometimes it’s necessary to get under the hood to discover what’s going on. Perhaps it’s because you’re tracing a bug or are just curious about how jQuery achieves a particular UI

10 fun jQuery game plugins to make your website more attractive and enhance user stickiness! While Flash is still the best software for developing casual web games, jQuery can also create surprising effects, and while not comparable to pure action Flash games, in some cases you can also have unexpected fun in your browser. jQuery tic toe game The "Hello world" of game programming now has a jQuery version. Source code jQuery Crazy Word Composition Game This is a fill-in-the-blank game, and it can produce some weird results due to not knowing the context of the word. Source code jQuery mine sweeping game

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

This tutorial demonstrates how to create a captivating parallax background effect using jQuery. We'll build a header banner with layered images that create a stunning visual depth. The updated plugin works with jQuery 1.6.4 and later. Download the
