สมมติว่าเรามีคลาสชื่อ Foo()
ซึ่งรับค่าเป็นอาร์กิวเมนต์และมีเมธอดบางอย่าง method1, metohd2,...
let y = new Foo(56);
console.log(y) // output should be 56 not the class object
y.addOne() // output: adds one to the value
console.log(y) // output should be 57
เราทำสิ่งนี้ได้ไหม? ไม่โดยเฉพาะกับ Numbers
เท่านั้น แต่ยังมีประเภทข้อมูลอื่นด้วยใช่ไหม
let
คือ ES6 - person Nick Parsons   schedule 22.08.2020Class.toString
ใน Java ฉันไม่คิดว่ามันเป็นไปได้ใน JavaScript - person Adam Azad   schedule 22.08.2020