How to: fmt.Println in JavaScript
Outputting to your shell or terminal to inform the user of the outcome of a program or valuable debugging information is an essential of every programming language.
GOlang
In Golang you can output text and variables to the terminal via various methods, but fmt is a commonly used one.
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
// Hello Jonathan!
name := "Jonathan"
fmt.Printf("Hello %s!\n", name)
fmt.Printf("1 + 1 is %d!\n", 1+1)
// %v for unknown variable types
fmt.Printf("unknown variable type: %v without newline", 40.1)
}
More fmt.Println References
JavaScript
In JavaScript console.log will print to the browser console or your shell where node.js is running your file:
// strings
console.log('Hello World!');
// multiple parameters
console.log('Hello', 'World!', 666);