Homoiconicity Test

Javascript program to test Homoiconicity

by Joy George Kunjikkuru

HTML

<button onclick="add_Click()"> mathLib.Add(2,3) function</button>
<button onclick="change_mathLibAdd()">Change mathLib.Add() to return product</button>

JavaScript

var mathLib={};
mathLib.Add = function (n1,n2){
    return n1+n2;
};
function add_Click(e){
    return alert(mathLib.Add(2,3));
}
function change_mathLibAdd(){
    mathLib.Add = function (n1,n2){
        return n1*n2
    };
    alert("Now click on above button to see Add() returning product instead of sum");
}