“Typscript -Variablentypen” Code-Antworten

Typscript Ganzzahl

// There is no int type, use number
const myInt: number = 17;
const myDecimal: number = 17.5;
Arrogant Ape

Typscript -Variablentypen

let name: string; // stores text
let age: number; // stores numbers
let isMale: boolean; // stores a true or false values
let typeAny: any; // stores any type of value
let typeNull: null = null; // can only store a null value
let typeUndefined: undefined = undefined; // can only store undefined value

// these are the basic types of variables in TypeScript
// and of course you can change let to const
ST111

So definieren Sie Typen in TypeScript

type Person = {
  name: string;
  age: number;
};

const person: Person {
	named: 'Rex'
  	age: 23
}
 
function greet(person: Person) {
  return "Hello " + person.name;
}
REX OMIV

So definieren Sie Typen in TypeScript

interface Person {
  name: string;
  age: number;
}

const person:Person {
	name: "Rex",
    age: 20
}
 
function greet(person: Person) {
  return "Hello " + person.name;
}
REX OMIV

Winkelstyp Saite

if(typeof myVariable === 'string'){
	//do
}
ChernobylBob

Datentyp Angular

let decimal: number = 6;
let hex: number = 0xf00d;
let binary: number = 0b1010;
let octal: number = 0o744;
let big: bigint = 100n;Try
Grieving Gharial

Ähnliche Antworten wie “Typscript -Variablentypen”

Fragen ähnlich wie “Typscript -Variablentypen”

Weitere verwandte Antworten zu “Typscript -Variablentypen” auf TypeScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen