Ad Home

Theme images by kelvinjay. Powered by Blogger.

Travel

Header Ads

Java

Selenium

UFT

Framework

General QA Concept

BDD

» » Few Rules on JavaScript


A variable is defined a temporary storage for holding mainly values.Javascript variables do not have script type hence any variable can take any values.A variable is popularly defined as "var".
Variable's value can be changed any point of time.


var Fname="Askqtp";
again,
var Fname=1;


Rules to check the javascript syntax..



  • Any statement should end witha  semicolon (;).
  • Any comment should be started with "//". or please your comment inside "<! your comment goes here> "
  • White space is not a concern for javascript (Var                       FName             =             "Askqtp              ;         " is equal to  var Fname="Askqtp";)
  • Any string when defined should be put inside a set of double quote (var fName="Askqtp")
  • Deceleration of variable is just for assign some space is memory . it does not mean you need to assign something to it. by default javascript engine will assign undefined value to it. 
  • Boolean variables can take either true or false.but please do not use quote when using it.
  • Any variable deceleration should be string type like Var askQTP (This is what I like ) but it supports underscore and dollar sign before a string as variable name.
  • Please do not use any variable starting with other special character or number
  • Do not use any special character between the variable name.
  • Please do not use javascript reserved keyword. you can find it here http://www.quackit.com/javascript/javascript_reserved_words.cfm  
  • While deceleration of variable,the upper and lower case matters and interpreted as two different variables.
  • Javascript tries to convert everything into string.Be careful when you are working with String and numeric data.
    function ani()
    {
    var ani=2+"i love code";
    alert(ani);
    Here 2 is numeric and rest part is string. But javascript parser made everything as a string.
    I will publish more on this once I will  get to know.

  • «
    Next
    Newer Post
    »
    Previous
    Older Post

    No comments:

    Leave a Reply