Uğur Canbulat Uğur Canbulat - 1 year ago 70
Javascript Question

Javascript agglutinative function

Hey guys my question is "What is this , what is the function like this document.getElementById , how can i write a function like this" i am new on it i just want to know how to do it
And i tryed like this

function person(something) {
this.something = something;
a.something = "value";

but i want to rewrite the "getAttribute()" function in my language and in my library. Someone can help me ?
NOTE: Sorry about english i know it is worst ever.

my wish

function say(avalue){
var a = "something";

//output "alert("something");"

Answer Source

Okay, i think this is what you're looking for:

    Ozellik: function(attr) {
        return this.attr(attr);


<a id="mavi">link</a>

$('a').Ozellik('id')// > 'mavi'

You can apply this to plain JavaScript aswell:

Element.prototype.Ozellik = function(attr) {
    return this.getAttribute(attr);


<a id="mavi">link</a>

var _elem = document.getElementsByTagName('a')[0];
_elem.Ozellik('id'); // > 'mavi'