Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Javascript Datatype

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 128
    Comment on it

    Javascript data type can hold may data type like number string arrays object and other.
    To declare a variable we use var keyword
    example

    var length = 16;                               // Number
    var lastName = "Johnson";                      // String
    var cars = ["Saab", "Volvo", "BMW"];           // Array
    var x = {firstName:"John", lastName:"Doe"};    // Object
    

    The Concept of Data Types

    var x = 16 + "Volvo";
    

    It will consider both as String as the second operand is String.

    var x = 16 + 4 + "Volvo";
    

    It will consider first two operand as integer and third as a String.
    and will give result 20Volvo

    var x = "Volvo" + 16 + 4;
    

    It will consider second and third operand as a String now.
    \ and the result will be Volvo164.
    JavaScript Has Dynamic Types

     var x;               // Now x is undefined
    var x = 5;           // Now x is a Number
    var x = "John";      // Now x is a String
    

    JavaScript Strings

     var carName = "Volvo XC60";   // Using double quotes
    var carName = 'Volvo XC60';   // Using single quotes
    

    JavaScript Numbers

    var x1 = 34.00;     // Written with decimals
    var x2 = 34;        // Written without decimals
    

    JavaScript Booleans

    var x = true;
    var y = false;
    

    JavaScript Arrays
    var cars = ["Saab", "Volvo", "BMW"];
    JavaScript Objects

    print("code sample");
    

    var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: