Search By Label
usePathname
is a Client Component hook that lets you read the current URL's pathname.'use client' import { usePathname } from 'next/navigation' export default function ExampleClientComponent() { const pathname = usePathname() return <p>Current pathname: {pathname}</p> }
usePathname
intentionally requires using a Client Component. It's important to note Client Components are not a de-optimization. They are an integral part of the Server Components architecture.<Link key={link.name} href={link.href} className={clsx( 'flex h-[48px] grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 text-sm font-medium hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3', { 'bg-sky-100 text-blue-600': pathname === link.href, }, )} > <LinkIcon className="w-6" /> <p className="hidden md:block">{link.name}</p> </Link>
debugger
statement directly in your Node code to create breakpoints. When the Node runtime hits the debugger
statement, it will pause execution if a debugger is attached.function exampleFunction() { const value = 42; debugger; // Execution will pause here if a debugger is attached console.log(value); } exampleFunction();
--inspect
or --inspect-brk
flag when running your app.node --inspect --5120 lib/app.js
Debugger listening on ws://127.0.0.1:9229/65b96f6d-6202-49db-bbe8-63b706a580a2
x = 10 y = x print(id(x)) # Output: 140737469306640 print(id(y)) # Output: 140737469306640
x
and y
refer to the same integer object with the memory address 140737469306640
. The reference count of this object is 2.del x print(id(y)) # Output: 140737469306640
x
, the reference count of the integer object becomes 1. Since y
is still pointing to it, the object is not garbage collected.def add_items(n): return n + n + n print add_items(10)
The O(N^2) time complexity means that the running time of an algorithm grows quadratically with the size of the input. It often involves nested loops, where each element in the input is compared with every other element.
def print_items(n): for i in range(n): for j in range(n): print(i,j) print_items(10)
def print_items(n): for i in range(n): for j in range(n): print(i,j) for k in range(n): print(k) print_items(10)
O(n)
for the simple search. It's a guarantee that the simple search will never be slower than O(n) time. In a code where the worst scenario is go thought all the elements the notation is O(n)
def print_items(n): for i in range(n): print(i) print_items(10)