Skip to content

Instantly share code, notes, and snippets.

View Ladvace's full-sized avatar
:octocat:
Focusing

Gianmarco Ladvace

:octocat:
Focusing
View GitHub Profile
<html>
<head>
<title>Party Coffee Cake</title>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Recipe",
"name": "Party Coffee Cake",
"author": {
"@type": "Person",
<html>
<head>
<title>Party Coffee Cake</title>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Recipe",
"name": "Party Coffee Cake",
"author": {
"@type": "Person",
Symbol('bar') === Symbol('bar') // false, each of them it's a unique id, the "bar" it's just a description and not an unique key
Symbol.for('foo'); // create a new global symbol
Symbol.for('foo'); // retrieve the already created symbol
Symbol.for('bar') === Symbol.for('bar') // true
let obj = {}
const symbol1 = Symbol("a")
const symbol2 = Symbol("a")
const sharedSymbol = Symbol.for('b')
obj[symbol1] = 'a'
obj[sharedSymbol] = 'b'
obj['c'] = 'c'
import React, { useState } from 'react'
export const Component = ({name, age}) => {
return (
<div>
<h2>{name}</h2>
<p>{age}</p>
</div>
)
import React, { useState } from 'react'
export const Component = (props) => {
return (
<div>
<p>{props.name}</p>
<p>{props.surname}</p>
<p>{props.age}</p>
<p>{props.location}</p>
import React, { useState } from 'react'
export const Component = () => {
const [show, setShow] = useState(false)
const handleClick = () => {
setShow(prev => !prev)
}
return (
import React, { useState } from 'react'
export const Component = () => {
const [show, setShow] = useState(false)
const handleClick = () => {
setShow(prev => !prev)
}
return (
<script context="module">
export async function load({ fetch, page }) {
let article;
try {
// here we are gonna fetch the single article by id
article = await fetch(`https://dev.to/api/articles/${page.params.slug}`);
article = await article.json();
} catch (e) {
<script context="module">
// this script fetch the posts from the api
// https://svelte.dev/docs#script_context_module
// this is runned on load (check svelKit doc)
export async function load({ fetch }) {
let articles;
try {
// here you should type your dev.to username