deno javascript code example

Example 1: install deno

#Using Shell (macOS and Linux):
curl -fsSL https://deno.land/x/install/install.sh | sh

#Using PowerShell (Windows):
iwr https://deno.land/x/install/install.ps1 -useb | iex


#Using Scoop (Windows):
scoop install deno

#Using Chocolatey (Windows):
choco install deno

#Using Homebrew (macOS):
brew install deno

#Using Cargo (Windows, macOS, Linux):
cargo install deno

Example 2: array.splice javascript

const months = ['Jan', 'March', 'April', 'June'];
months.splice(1, 0, 'Feb');
// inserts at index 1
console.log(months);
// expected output: Array ["Jan", "Feb", "March", "April", "June"]

months.splice(4, 1, 'May');
// replaces 1 element at index 4
console.log(months);
// expected output: Array ["Jan", "Feb", "March", "April", "May"]

months.splice(0, 1);
// removes 1 element at index 0
console.log(months);
// expected output: Array ["Feb", "March", "April", "May"]

Example 3: denojs

$cargo install deno

Example 4: denojs

$iwr https://deno.land/x/install/install.ps1 -useb | iex

Tags:

Misc Example