programmering:martins_js-cheatsheet
−Table of Contents
JS Cheatsheet
Simple typer
boolean, number, string, null, undefined
console.log(typeof "JavaScript"); // "string" console.log(typeof 10); // "number" console.log(typeof 5.1); // "number" console.log(typeof true); // "boolean" console.log(typeof undefined); // "undefined" console.log(typeof null); // "object"
Built-in typer
Array, Date, Error, Function, Object, RegExp
var items = new Array(); var now = new Date(); var error = new Error("Something bad happened."); var func = new function("console.log('Hi');"); var object = new Object(); var re1 = new RegExp("\\d+","g"); var re2 = /\d+/g;
programmering/martins_js-cheatsheet.txt · Last modified: 2023/10/21 19:19 by 127.0.0.1