Download Source Code Aplikasi

Prototype

Tuesday, January 14th, 2020 - JavaScript » Boolean

Properti Boolean.prototype menambahkan properti gres atau metode gres kepada objek Boolean.

Sintaks:

Boolean.prototype.property Boolean.prototype.method

Boolean.prototype yaitu properti standard JavaScript 1.1+, JScript 3.0+, ECMAScript 1.0+ dan di dukung Google Chrome Beta+, Firefox 1.0 (Gecko 1.7)+, Internet Explorer 4.0+, Netscape Navigator 3.0+, Opera 3.0+, Safari 1.0+.

Contoh di bawah ini menambahkan metode gres berjulukan newMethod, beliau memiliki fungsi jikalau objek Boolean bernilai true, maka false dikembalikan, begitu sebaliknya:

var boolean_1 = new Boolean(true); var boolean_2 = new Boolean(false); Boolean.prototype.newMethod = function() { if(this.valueOf() == true) { return false; } else{ return true; } } alert(boolean_1.newMethod()); // false alert(boolean_2.newMethod()); // true
Demikian yang dapat kami share kepada sobat source code aplikasi pada kesempatan ini, semoga dapat bermanfaat dan bisa menjadi referensi pemrograman bagi anda. Jangan lupa like Fan Page kami, dan SUBSCRIBE Channel Youtube kami untuk dapatkan update source code aplikasi terbaru.
Download Source Code Aplikasi
Prototype | Ahmad Code | 4.5