Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get retrun types of variables in JS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 129
    Comment on it

    Hello Reader's if you want to get the return types of the variables in Javascript then in this blog you will learn about them.

    for getting the return type you have to use the type of function in the JavaScript.
    Let's see some of the return type with the variables below:-

    <script>
    document.getElementById("demo").innerHTML = 
        typeof "john" + "<br>" +
        typeof 3.14 + "<br>" +
        typeof NaN + "<br>" +
        typeof false + "<br>" +
        typeof [1,2,3,4] + "<br>" +
        typeof {name:'john', age:34} + "<br>" +
        typeof new Date() + "<br>" +
        typeof function () {} + "<br>" +
        typeof myCar + "<br>" +
        typeof null;
    </script>
    

    Output:-

    string
    number
    number
    boolean
    object
    object
    object
    function
    undefined
    object
    

 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: