List of JavaScript postfix completion templates
This table summarizes the postfix completion templates that you can use with your JavaScript code.
Name | Description | Example. Before | Example. After |
---|---|---|---|
| Wraps an expression in an if statement that checks that the expression doesn't value to null. |
function m(arg) {
if(isNaN(arg)!) {
}
}
|
function m(arg) {
if(!isNaN(arg)) {
}
}
|
| Wraps an expression in a function call. |
function m(id) {
id.arg
}
|
function m(id) {
foo(id)
}
|
| Inserts an await before the value of an async function. |
async function m() {
fetch('/users.json').await
}
|
async function m() {
await fetch('/users.json')
}
|
| Introduces a const variable for an expression. |
function m(id) {
document.getElementById(id).const
}
|
function m(id) {
const el = document.getElementById(id);
}
|
| Introduces a destructuring pattern for an expression. |
class Person {
name;
age;
}
new Person().destruct
|
class Person {
name;
age;
}
let {} = new Person();
|
| Introduces a destructuring pattern for all elements of an expression. |
class Person {
name;
age;
}
new Person().destructAll
|
class Person {
name;
age;
}
let {age, name} = new Person();
|
| Iterates over an object via its Symbol.iterator or over the values of an array using a destructuring pattern. |
let arg = [{x: "string1"}, {x: "string2"}];
arg.dforof
|
let arg = [{x: "string1"}, {x: "string2"}];
for (let {x} of arg) {
}
|
| Wraps a boolean expression in an if statement that checks that the expression values to false. |
function m(arg) {
arg.else
}
|
function m(arg) {
if(!(arg)) {
}
}
|
| Iterates over the indices of an object. |
let arg = ["string1", "string2"];
arg.fori
|
let arg = ["string1", "string2"];
for (let i = 0; i < arg.length; i++) {
}
|
| Iterates over the keys of an object. |
function m(arr) {
arr.forin
}
|
function m(arr) {
for (var element in arr) {
}
}
|
| Iterates over an object via its Symbol.iterator or over the values of an array. |
let arg = ["string1", "string2"];
arg.forof
|
let arg = ["string1", "string2"];
for (let obj of arg) {
}
|
| Iterates over the indices of an object in the reverse order. |
let arg = ["string1", "string2"];
arg.forr
|
let arg = ["string1", "string2"];
for (let i = arg.length - 1; i >= 0; i--) {
}
|
| Wraps a boolean expression in an if block that checks the expression values to true. |
function m(arg) {
arg.if
}
|
function m(arg) {
if(arg) {
}
}
|
| Wraps an expression in an if block with an instanceof check. |
function processData(data) {
data.instanceof
}
|
function processData(data) {
if (data instanceof ) {
}
}
|
| Iterates over the keys of an object. |
function m(arr) {
arr.itin
}
|
function m(arr) {
for (var element in arr) {
}
}
|
| Introduces a let variable for an expression. |
function m(id) {
document.getElementById(id).let
}
|
function m(id) {
let el = document.getElementById(id);
}
|
| Inserts a console.log call. |
function m(id) {
var el = document.getElementById(id);
'element: ' + el.log
}
|
function m(id) {
var el = document.getElementById(id);
console.log('element: ' + el);
}
|
| Wraps an expression in an if statement that checks that the expression doesn't value to null. |
function m(arg) {
if(isNaN(arg).not) {
}
}
|
function m(arg) {
if(!isNaN(arg)) {
}
}
|
| Wraps current expression in a not-null checking statement |
function m(arg) {
arg.notnull
}
|
function m(arg) {
if(arg != null) {
}
}
|
| Wraps an expression in an if statement that checks that the expression values to null. |
function m(arg) {
arg.null
}
|
function m(arg) {
if(arg == null) {
}
}
|
| Wraps an expression in parentheses. |
function m(arg) {
if(arg == 1.par) {
}
}
|
function m(arg) {
if((arg == 1)) {
}
}
|
| Wraps an expression in a return statement. |
function m() {
"result".return
}
|
function m() {
return "result";
}
|
| Wraps an expression in a switch statement and generates case clauses when possible. |
/**
* @param {'header' | 'footer'} templateKind
*/
function getTemplate(templateKind) {
templateKind.switch
}
|
/**
* @param {'header' | 'footer'} templateKind
*/
function getTemplate(templateKind) {
switch (templateKind) {
case 'header':
break;
case 'footer':
break;
}
}
|
| Wraps an expression in a throw statement. |
function m(arg) {
if(arg == null) {
new Error('arg null').throw
}
}
|
function m(arg) {
if(arg == null) {
throw new Error('arg null');
}
}
|
| Applies the typeof operator to an expression. |
function m(arg) {
var type = arg.typeof
if (type == 'number') {
}
}
|
function m(arg) {
var type = typeof arg
if (type == 'number') {
}
}
|
| Wraps an expression in an if block with a typeof check. |
function processData(data) {
data.typeofif
}
|
function processData(data) {
if (typeof data === "") {
}
}
|
| Wraps an expression in an if statement that checks that the type of the expressions is not undefined. |
function m(arg) {
arg.undef
}
|
function m(arg) {
if(typeof arg !== "undefined") {
}
}
|
| Introduces a var variable for an expression. |
function m(id) {
document.getElementById(id).var
}
|
function m(id) {
var el = document.getElementById(id);
}
|