📜  我的 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:21.106000             🧑  作者: Mango

代码示例1
const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

var points = [40, 100, 1, 5, 25, 10];
points.sort((a,b) => a-b)

var newArray = array.filter(function(item) {
  return condition;
});

var promise = new Promise(function(resolve, reject) {
  // do some long running async thing…
  
  if (/* everything turned out fine */) {
    resolve("Stuff worked!");
  }
  else {
    reject(Error("It broke"));
  }
});

app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))