# How to read javascript code in js libraries ?

**URL:** <https://forum.kirupa.com/t/how-to-read-javascript-code-in-js-libraries/634332>\
**Category:** programming\
**Created:** [March 11, 2016, 7:10am UTC](https://forum.kirupa.com/t/how-to-read-javascript-code-in-js-libraries/634332 "2016-03-11T07:10:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vmars316](https://avatars.discourse-cdn.com/v4/letter/v/bcef8e/32.png) [@vmars316](https://forum.kirupa.com/u/vmars316)\
**Post date:** [March 11, 2016, 7:10am UTC](https://forum.kirupa.com/t/how-to-read-javascript-code-in-js-libraries/634332/1 "2016-03-11T07:10:42Z")

</div>

Hello & Thanks ,  
I am fairly new to javascript coding . And am working with a js library named Quickjs .

I would like to learn how to read/understand any javascript library :

In reference to Quickjs library: [https://github.com/dgsprb/quick/wiki/API](https://github.com/dgsprb/quick/wiki/API)

My complete source code 🙂 [http://pastebin.com/YezzaXX6](http://pastebin.com/YezzaXX6)  
Source code for Quick.js [pastebin.com/1fhT2uBY](http://pastebin.com/1fhT2uBY)

It occurs to me that maybe I could find out which button was clicked by using the the hasTag method .

But I get into trouble , error: ~paddle-main-NOW.js:63 Uncaught TypeError: RestartBtn.hasTag is not a function

when I try: RestartBtn.prototype.update = function () {

```
        if (this.pointer.getPush()) {  

```

// if (GameObject.hasTag(“restartBtn”)) { // doesnt work

// if (this.hasTag(“restartBtn”)) { // doesnt work

```
		     if (RestartBtn.hasTag("restartBtn")) {  

            alert('restartBTN = ' + restartBTN); }; }; }; 			    

```

Pls , tell me why the following works , and the above doesnt ?

```
Ball.prototype.onCollision = function (GameObject) { 

    var collision = this.getCollision(GameObject); 

    if (GameObject.hasTag("lies02")) { 

	    lies02.setLeft(0);  

```

Thanks…Vern

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [March 12, 2016, 6:44am UTC](https://forum.kirupa.com/t/how-to-read-javascript-code-in-js-libraries/634332/2 "2016-03-12T06:44:02Z")

</div>

From what you’ve pasted, GameObject doesn’t seem to be a global variable. It is passed into the function you are in. For example, `onCollision` passes in `GameObject`. Your `RestartBtn.prototype.update` function doesn’t seem to provide for a `GameObject` argument.

If you set a breakpoint inside your update function, go to the Console and see what the value of GameObject is and whether it has a hasTag method built on it.

🙂

---

<div class="post-metadata">

**Author:** ![vmars316](https://avatars.discourse-cdn.com/v4/letter/v/bcef8e/32.png) [@vmars316](https://forum.kirupa.com/u/vmars316)\
**Post date:** [March 16, 2016, 3:14pm UTC](https://forum.kirupa.com/t/how-to-read-javascript-code-in-js-libraries/634332/3 "2016-03-16T15:14:11Z")

</div>

> [@kirupa](#):
>
> If you set a breakpoint inside your update function, go to the Console and see what the value of GameObject is and whether it has a hasTag method built on it.

This is very helpful…Thanks
