Javascript:void (0) meaning, code specification

Source: Internet
Author: User

1.javascript:void (0) meaning

We often use code such as Javascript:void (0), so what does javascript:void (0) mean in JavaScript?

The key in Javascript:void (0) is the Void keyword, which is a very important keyword in JavaScript, which specifies that an expression is evaluated but does not return a value.

"text/javascript"><!--void  func () javascript:void  func () or void(func ()) javascript:void(func ())//-</script>

The following code creates a hyperlink, and nothing happens when the user clicks it.

"text/javascript"><!--// - </script>"javascript:void (alert (' Warning!!! ')) "> Point me!</a></body>

Parameter A in the following instance returns undefined:

"Text/javascript"><!--function GetValue () {varA,b,c; A=void(b =5, C =7 ); document.write ('A ='+ A +'B ='+ B +'C ='+c);}// -</script>

The difference between 1.1href= "#" and href= "javascript:void (0)"

# contains a location information, the default anchor is #top that is the top of the page.

and javascript:void (0), only represents a dead link.

When the page is long, it uses # to locate the page in the format:# + ID.

If you want to define a dead link please use Javascript:void (0).

<a href="javascript:void (0); "> Point I did not respond to!</a><a href="#pos"> Point I positioned to the specified position!</a><br> ... <br><p id="pos"> trailing anchor points </p>

2.JavaScript Code Specification

The same specification applies to all JavaScript projects.

2.1JavaScript Code Specification

Code specifications typically include the following:

    • Naming rules for variables and functions
    • Whitespace, indentation, usage rules for annotations.
    • Other common specifications ...

The code of the specification can be easier to read and maintain.

Code specifications are generally defined prior to development and can be negotiated with your team members to set up

2.2 Variable Name

The name of the variable is recommended using the Hump method (CamelCase):

" John "  "Doe"19.90 0.20= Price + (Price * tax);

2.3 Spaces and operators

The usual operators (= +-*/) need to add spaces before and after:

var x = y + z; var values = ["Volvo""Saab""Fiat "];

2.4 Code Indentation

You typically use 4 space symbols to indent a block of code:

Function:
function Tocelsius (Fahrenheit) {    return (59);}

2.5 Statement Rules

General rules for simple statements:

    • A statement usually has a semicolon as the Terminator.
varvalues = ["Volvo","Saab","Fiat"];varperson ={firstName:"John", LastName:"Doe", Age: -, Eyecolor:"Blue"};

General rules for complex statements:

    • Place the left curly brace at the end of the first line.
    • Add a space before the left curly brace.
    • Put the right curly brace on one line independently.
    • Do not end a complex declaration with a semicolon.
Function:
function Tocelsius (Fahrenheit) {    return (59);}
Cycle:
 for 0 5; i++) {    + = i;}
Conditional statements:
if  - {    "goodday"Else  {    "  Good evening";}

2.6 Object Rules

Rules for object definitions:

    • Put the left curly brace on the same line as the class name.
    • There is a space between the colon and the attribute value.
    • Strings use double quotes, and numbers are not required.
    • Do not add a comma after the last property-value pair.
    • Place the right curly brace on one line independently and with a semicolon as the ending symbol.
Instance:
var person = {    "John",    "Doe"  ,    "blue"};     

Short object code can be written directly into one line:

var person = {firstName:'John', LastName:'Doe', Age: eyecolor:"blue"};

2.7 Code characters per line less than 80

For readability each line of characters is suggested to be less than 80.

If a JavaScript statement exceeds 80 characters, it is recommended that you wrap the operator or comma after the line.

document.getElementById ("demo"). InnerHTML =    "Hello runoob. ";

2.8 Naming conventions

In general, many code language naming conventions are similar, for example:

    • Variables and functions are identified by the small hump method, that is, except for the first word, the first letter of the word is capitalized ( lowercamelcase)
    • Global variable is uppercase (uppercase )
    • A constant (such as PI) is capitalized (uppercase )

Variable name do you use these kinds of rules: hyp-hens, CamelCase, or under_scores ?

HTML and CSS's Bar (-) characters:

The HTML5 property can be prefixed with data-(such as: Data-quantity, Data-price).

CSS uses-to connect the property name (Font-size).

Javascript:void (0) meaning, code specification

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.