Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Dima-JS-SnippetsNew to Visual Studio Code? Get it now.
Dima-JS-Snippets

Dima-JS-Snippets

Dimitri10

|
357 installs
| (1) | Free
simple js snippets
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Javascript Code Snippets

keywords before "→" are what triggers autocomplete

Loops

Keywords Outcome
floop for (let i = 0; i < arr.length; i++){}
fin for (let key in obj) {console.log(key)}
fof for (let element of arr) {console.log(element)}

Placeholder Data

dummyobj → const user1 = {
  firstName: "John",
  lastName: "Doe",
  age: 39,
  onlineStatus: false,
  address: {
    state: "California",
    street: "39th street"
  }
}

dummyarr → const arr = ["john", "doe", -1, 0, 1, true, 3, 4];

Promise

newprom → const promiseName = new Promise((resolve, reject) => {
  resolve();
  reject();
})

returnprom → return new Promise((resolve, reject) => {})

JSONPlaceholder URL with different endpoints

jsonurl → const url = "https://jsonplaceholder.typicode.com/(users/posts/todos)"

Fetching Data

asfun → async function functionName(){
  const data = await fetch(url)
  const response  = await data.json();
  console.log(response);
}
functionName()
thenfun → function functionName(){
  fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.log(error))
}
functionName()

Console

clog → console.log()
ctime →  console.time() console.timeEnd()
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft