Code Examples

Examples With Multiple Languages

Multilanguage Code Samples
// Arrow function sample
const arrowFuncSample = () => {
console.log('this is an arrow function example');
};

Example With One Language

JavaScript

JavaScript Code SampleJavaScript
// Arrow function sample
const arrowFuncSample = () => {
console.log('this is an arrow function example');
};

Java

public class MyClass {
public static void main(String[] args) {
System.out.println("Hello World");
}
}

Scala

object HelloWorld {
def main(args: Array[String]) {
println("Hello, world!")
}
}

CSharp

CSharp Code SampleC#
using System;
namespace HelloWorld {
class Starter {
static void Main(string[] args) {
Console.WriteLine("Hello World!");
}
}
}

cURL

Curl Code SamplecURL
curl --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{"personalizations": [{"to": [{"email": "recipient@example.com"}]}],"from": {"email": "sendeexampexample@example.com"},"subject": "Hello, World!","content": [{"type": "text/plain", "value": "Heya!"}]}'

GraphQL

GraphQL Code Samplegraphql
type Person {
id: ID!
name: String!
age: Int
}

JSON

{
"petType": "Tarantula",
"name": "Squishy"
}

PHP

<!DOCTYPE html>
<html>
<head>
<title>Hello World Example</title>
</head>
<body>
<?php
echo "Hello world!";
?>
</body>
</html>

Shell

#!/bin/sh
echo Hello World

TypeScript

function sayHello(name: string) {
console.log(`Hello ${name}`);
}

YAML

- title: Menu
pages:
- title: Home
path: /home
- title: About
path: /about
- title: Products
path: /products
- title: Contact
path: /contact

JSX

const users = [
{
id: 1,
name: 'John Doe',
email: 'john.doe@example.com'
},
{
id: 2,
name: 'Jane Doe',
email: 'jane.doe@example.com'
}
];
function User({ user }) {
return (
<ul>
<li>Name: {user.name}</li>
<li>Email: {user.email}</li>
</ul>
);
}
function App() {
return (
<main>
<h1>Users list</h1>
<hr />
{users.map(user => (
<User key={user.id} user={user} />
))}
</main>
);
}