Primitives
Examples
Filter
// The latest ECMAScript standard defines seven primitive data types:
// Boolean. true and false.
let b = true;
console.log(b);
// null. A special keyword denoting a null value. (Because JavaScript is case-sensitive, null is not the same as Null, NULL, or any other variant.)
let n = null;
console.log(null);
// undefined. A top-level property whose value is not defined.
let u1 = undefined;
let u2;
console.log(u1);
console.log(u2);
// Number. An integer or floating point number. For example: 42 or 3.14159.
let n1 = 42;
let n2 = 3.14159;
console.log(n1);
console.log(n2);
// BigInt. An integer with arbitrary precision. For example: 9007199254740992n.
let big = BigInt(9007199254740991);
console.log(big);
// String. A sequence of characters that represent a text value. For example: "Howdy"
let s = "Howdy";
console.log(s);
// Symbol (new in ECMAScript 2015). A data type whose instances are unique and immutable.
let sym1 = Symbol();
let sym2 = Symbol(42);
let sym3 = Symbol('foo');
console.log(sym1, sym2, sym3);
/*
Go supports following built-in basic types:
one boolean built-in boolean type: bool.
11 built-in integer numeric types: int8, uint8, int16, uint16, int32, uint32, int64, uint64, int, uint, and uintptr.
two built-in floating-point numeric types: float32 and float64.
two built-in complex numeric types: complex64 and complex128.
one built-in string type: string
*/
// "bool" type
b1 := true
b2 := false
// "string" type
s := "hello"
// "rune" type - represents a Unicode code point
grinning_face := rune(0xf09f9880)
// numbers
n1 := i8(2)
n2 := byte(10)
n3 := i16(10)
n4 := u16(10)
n5 := 123 // Has the type "int"
n6 := u32(10)
n7 := i64(10)
n8 := u64(10)
n9 := 0.32 // Has the type "f32"
n10 := f64(0.32)
// pointers
p1 := byteptr(&s)
p2 := voidptr(&s)