BigFont Blog
  • Home
  • About
  • Bibliography (Work)

javascript

A collection of 9 posts

Use a regular expression in VS Code's find/replace to replace && with JavaScript's optional chaining
vscode

Use a regular expression in VS Code's find/replace to replace && with JavaScript's optional chaining

In December 2019, optional chaining went to TC39 stage 4. Here is a regular expression to replace most instances of foo && foo.bar and baz && baz() with optional chaining.

  • Shaun Luttin
    Shaun Luttin
1 min read
javascript

this in functions, arrow functions, class methods, and class arrow function properties

Functions & Class Methods both bind this when/how/where they are called. it is sometimes called dynamic binding Arrow Function & Arrow Function Class Properties both bind this when/how/where they

  • Shaun Luttin
    Shaun Luttin
1 min read
javascript

Simple Fetch API Example

let request = new Request('https://localhost:5001/api/values'); fetch(request) .then((response) => response.json()) .then((json) => console.log(json)); https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

  • Shaun Luttin
    Shaun Luttin
1 min read
javascript

Simple Example of Using the Browser's History API

This little History API demo hooks in to the browser button. We ran it using the the Firefox Developer Console. The demo does three things: Adds an onpopstate = (e) => console.log(e.

  • Shaun Luttin
    Shaun Luttin
1 min read
import m = require("m") vs import * as m from "m"
nodejs

import m = require("m") vs import * as m from "m"

Image by Varsha Y S (Own work) [CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0)], via Wikimedia Commons If you think you understand quantum mechanics, you don't understand quantum mechanics.

  • Shaun Luttin
    Shaun Luttin
2 min read
nodejs

Copy to clipboard from NodeJS

const output = "some string"; require("child_process").spawn("clip").stdin.end(output);

  • Shaun Luttin
    Shaun Luttin
1 min read
VSTS Test Coverage with Mocha, Istanbul, NYC, Coburtura and Junit
javascript

VSTS Test Coverage with Mocha, Istanbul, NYC, Coburtura and Junit

package.json "scripts": { "test": "nyc -r cobertura -r html mocha **/*test*.js -R mocha-junit-reporter" }, "devDependencies": { "mocha": "^2.5.3", "mocha-junit-reporter&

  • Shaun Luttin
    Shaun Luttin
1 min read
The power of ES 2017 (es8) in TypeScript even with NodeJS 6.11.0
typescript

The power of ES 2017 (es8) in TypeScript even with NodeJS 6.11.0

{ "compilerOptions": { "module": "commonjs", "target": "es6", "lib": [ "es2017", "dom" ] }, "exclude": [ "node_modules" ] } This tsconfig.

  • Shaun Luttin
    Shaun Luttin
1 min read
javascript

Legitimate uses of undefined in JavaScript

As function argument placeholders? Yes. To mark a variable for garbage collection? Yes. For instantiation? No. let x = undefined; // don't do this

  • Shaun Luttin
    Shaun Luttin
1 min read
BigFont Blog © 2022
Latest Posts Ghost