How do you console a variable?
How do you pass a variable in console log?
console. log takes multiple arguments, so just use: If name is an object or an array then using multiple arguments is better than concatenation. If you concatenate an object or array into a string you simply log the type rather than the content of the variable.
Should I use console log?
Yes. console. log will throw an exception in browsers that don’t have support for it (console object will not be found). Generally yes, its not a great idea to expose log messages in your production code.
When should you use console log?
- Numbers: 5, 6.5, 7 etc.
- String: “Hello GeeksforGeeks” etc.
- Boolean: Represent a logical entity and can have two values: true or false.
- Null: This type has only one value : null.
- Undefined: A variable that has not been assigned a value is undefined.
Press Command+Option+J (Mac) or Control+Shift+J (Windows, Linux, Chrome OS) to open the Console, right here on this very page.