Skip to content

Instantly share code, notes, and snippets.

View goofmint's full-sized avatar

Atsushi goofmint

View GitHub Profile
class Hello {};
const hello = new Hello;
hello.constructor.name;
// -> "Hello"
typeof 1
// -> "number"
typeof 0.001
// -> "number"
0.001.constructor.name
// -> "Number"
isNaN(0.001)
// -> false
isNaN(1)
// -> false
1.constructor.name
// -> Uncaught SyntaxError: Invalid or unexpected token
"Hello".constructor.name
// -> "String"
(new Date).constructor.name
// -> "Date"
true.constructor.name
// -> "Boolean"
Array.isArray(['a', 'b'])
// -> true
Object.prototype.toString.call(['a', 'b']) === '[object Array]'
// -> true
typeof new Array('a', 'b')
// -> "object"
typeof ['a', 'b']
// -> "object"
#[wasm_bindgen(start)]
pub fn run() {
log(&format!("Hello, {}!", name()));
let x = MyClass::new();
assert_eq!(x.number(), 42);
x.set_number(10);
log(&x.render());
}