Page 48 - JavaScript
P. 48

explicit return value.





        Logging variables



        console.log() can be used to log variables of any kind; not only strings. Just pass in the variable
        that you want to be displayed in the console, for example:


         var foo = "bar";
         console.log(foo);


        This will log the following to the console:
















        If you want to log two or more values, simply separate them with commas. Spaces will be
        automatically added between each argument during concatenation:


         var thisVar = 'first value';
         var thatVar = 'second value';
         console.log("thisVar:", thisVar, "and thatVar:", thatVar);


        This will log the following to the console:

























        Placeholders




        You can use console.log() in combination with placeholders:


         var greet = "Hello", who = "World";


        https://riptutorial.com/                                                                                5
   43   44   45   46   47   48   49   50   51   52   53