Perfecting this task is within my grasp:
let Object = {};
Object.method = function(){alert("This is a method of 'Object' ")};
This approach also yields results:
let Object={method:
{property:"A property within a method",
method_property:function(){alert(this.property)}
}
};
Object.method.method_property();
I've another idea in mind, let me show you my perspective on the matter:
let Object = {};
Object.method = function(){alert("This is a method of 'Object'")};
Object.method.property = "This is a property of 'Object.method()' ";
Object.method.method_property = function(){alert(Object.method.property)};
Object.method.method_property();
Object.method(); // I have defined this method, how can I achieve this with an object literal if possible
Now consider this, it poses my question:
let Object = {method:function(){
alert("This does not work")};{method_property:function(){
alert("Neither does this work")};
My aim: Object.method(); // alert this does not work with the object literal. The same intention as before: Object.method.method_property();// neither works but in the previously mentioned methods I performed the same action, so is it incorrect to do so?
If further clarity is needed to understand my query:
let Objeto(){method:function(){{another_method:function(){alert("How do I give value to the method prior to this one inside the literal, of course")}}};
let Object = {method:{another_method(){alert("It works but 'Object.method' is actually a property and not a method")}}}
Objeto.method.another_method();
The main question is simple - can I assign a value to a method and introduce a new method within an object literal?