Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i m creating a shortcut language for javascript, i m tired of those long camel case method, so here i want document as d.

What I have tried:

Object.prototype.d = function ()
{
document.this;
};

d.write("hello);

/* i want d.write("hello"); instead of document.write("hello"); */
Posted
Updated 29-Jul-16 23:50pm
Comments
What is the issue?

try this

JavaScript
var d = document;
 d.write("hello");  
 
Share this answer
 
You are referencing document.this, not document itself. And the object you are having does not have a definition for "write". So instead of that, try this:
JavaScript
var d = document;
d.write("Hello, world!");

Try this here: Edit fiddle - JSFiddle[^].
 
Share this answer
 
Comments
prasad sawant 30-Jul-16 8:50am    
oh my god it was so simple.. and i thought it is hard..

one more question..

i want this..

d = document;
o = Object;
p = prototype;
t = this;

o.p.w = w(markUp)
{
t.write(markUp);
};

d.w("hello");

/* somehow my code doesnt work any solution */
Afzaal Ahmad Zeeshan 30-Jul-16 10:21am    
Please start a new thread for this question since this question has been answered, and we can continue on that thread.
prasad sawant 30-Jul-16 10:37am    
ok

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900