W3Schools

 

home HOME

JS Basic
JS HOME
JS Introduction
JS How To
JS Where To
JS Variables
JS Operators
JS Functions
JS Conditional
JS Looping
JS Guidelines

JS References
JS String Object
JS Array Object
JS Date Object
JS Math Object
JS Window Object
JS Frame Object
JS Form Object
JS Browser Object

Examples/Quiz
JS Examples
JS Quiz

JavaScript Guidelines

previous next

Some things to know about JavaScript. 


JavaScript is Case Sensitive

A function named "myfunction" is not the same as "myFunction". Therefore watch your capitalization when you create or call variables, objects and functions. 


Symbols

Open symbols, like  ( { [ " ', must have a matching closing symbol, like  ' " ] } ).


White Space

JavaScript ignores extra spaces. You can add white space to your script to make it more readable. These two lines mean exactly the same:

name="Hege"
name = "Hege"


Break up a Code Line

You can break up a code line within a text string with a backslash. The example below will be displayed properly:

document.write("Hello \
World!")

Note: You can not break up a code line like this:

document.write \
("Hello World!")

The example above will cause an error.


Insert Special Characters

You can insert special characters (like " ' ; &) with the backslash:

document.write ("You \& I sing \"Happy Birthday\".") 

The example above will produce this output:

You & I sing "Happy Birthday".


Comments

You can add a comment to your JavaScript code starting the comment with two slashes "//":

sum=a + b  //calculating the sum

You can also add a comment to the JavaScript code, starting the comment with "/*" and ending it with "*/"

sum=a + b  /*calculating the sum*/

Using "/*" and "*/" is the only way to create a multi-line comment:

/* This is a comment
block. It contains
several lines*/


previous next

Product Spotlight


Hosting Spotlight


Phone Cards

Phone Cards Online

International and domestic phone cards for US customers.

Great affiliate program.


We Help You For Free. You Can Help Us!


Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Google  Yahoo  Alta Vista  MSN  Lycos  Excite  Ask Jeeves  HotBot


W3Schools is for training only. We do not warrant the correctness of the content. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2004 by Refsnes Data. All Rights Reserved.


Validate How W3Schools was converted to XHTML Validate

Web charting
Web based charting
for ASP.NET


WEB HOSTING

$15 Domain Name
Registration
Save $20 / year!



UK Domain Names
Web Hosting
Merkaweb Dominios


Buy UK Domain Names
Register Domain Names


Website Hosting
Domain Hosting
Web Hosting


Cheap Domain Names UK


Domain Names UK
Quality Web Hosting
Webmail & POP3 Email


Web Hosting UK
Dedicated Servers UK
Domain Names UK


Business Web Hosting
Free Web Hosting
Cheap Web Hosting
Web Hosting Reseller


Website Design UK

HOTELS

Amsterdam Hotels
Boston Hotels
Chicago Hotels
London Hotels
Los Angeles Hotels
Miami Hotels
New York Hotels
New Orleans Hotels
Paris Hotels
Rome Hotels
Hotel Reservations


Hotel Directory
Hotel Rooms

Web Building

Website Templates
Website Builder
Flash Templates
Web Templates

Shopping

Garden decor
Online Coupons
Cooking tools
Men & women clothing
Office supply

Software

Student Price Software


Your Own Web Site?

Read W3Schools
Hosting Tutorial








WebDev Books

The Web Design Business Kit Grow Your Web Design Business!

HTML Utopia: Designing Without Tables Using CSS Learn CSS Positioning the easy way!

Build Your Own Database Driven Website Using PHP & MySQL Learn PHP & MySQL the easy way!

SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Security
Web Statistics
Web Standards

Web Quality