Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

Can't replicate inbuilt function in javascript

$
0
0

Why do built-in functions not have a prototype property?
I see a post on the above link but it is not solving my problem.

I am able to replicate some built in objects like

var w=window;
w.alert("hi");
var d=document;
console.log(d.getElementById);

But I can't replicate functions

var a=document.getElementById;
console.log(a);

The prototype gets copied but when invocating It is not working

var a=document.getElementById;
console.log(a('id'));

I use this to lower the coding effort. I know that I can achieve this by using

function a(id){
 return document.getElementById(id);
}
console.log(a('id'));

But this is not what I am looking for. Is there any other way to replicate a funciton


Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>