Few Rules on JavaScript

    0
    15
    Spread the love
    • 1
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
      1
      Share


    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.
  • Don't miss out!
    Subscribe To Newsletter

    Receive top technical news, lesson ideas, travel tips and more!

    Invalid email address
    Give it a try. You can unsubscribe at any time.

    Spread the love
    • 1
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
      1
      Share
    Previous article11 Reasons to Go for HTML 5
    Next articlePalindrome How it coded it
    I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on [email protected]

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here